I am trying to make the most simple example in the work using JNI4NET but can't do it and need help.
package jnijavatestapp;
import java.io.IOException;
import jnicsharptestapp.JNICSharpTest;
import net.sf.jni4net.Bridge;
public class JNIJavaTestApp
{
public static void main(String[] args) throws IOException {
InitJNI4Net();
JNICSharpTest test = new JNICSharpTest();
test.HelloWorldFromCSharp();
}
public static void InitJNI4Net() throws IOException{
Bridge.init();
java.io.File file = new java.io.File("..\\COMMON_RESOURCES\\work\\JNICSharpTestApp.j4n.dll");
Bridge.LoadAndRegisterAssemblyFrom(file);
}
}
and another simple JAVA class:
package jnijavatestapp;
public class JAVACLASS
{
public void HelloWorldJAVA()
{
System.out.println("Hi C# this is JAVA Talking!!");
}
}
All I want to be able to do is call the C# code from JAVA but ALSO CALL the JAVA code back from C#. Is this possible using JNI4NET? I want TWO WAY communication. But it seems that no matter what I do with the build order I can't get it to work.
Here is what I'm doing:
1.) Build C# Project
2.) Generate Proxies for C# app:
@echo off
cd COMMON_RESOURCES
echo.
echo Running ProxyGen.exe for C#...
..\JNI4NET\bin\proxygen.exe work\JNICSharpTestApp.dll -wd work
echo.
echo Building C#...
cd work
build
3.) Run build (called in above .bat)
4.) Generate JAVA Proxies:
@echo off
copy JNI4NET\lib\*.* COMMON_RESOURCES\work /y
copy JNIJavaTestApp\dist\JNIJavaTestApp.jar COMMON_RESOURCES\work /y
cd COMMON_RESOURCES
echo.
echo Running ProxyGen.exe for JAVA...
..\JNI4NET\bin\proxygen.exe ..\JNIJavaTestApp\dist\JNIJavaTestApp.jar -wd work
echo.
echo Building JAVA...
cd work
build
5.) Build again (called in above script also)
Messing around with above order I am able to call C# from JAVA but can never call JAVA from C# without it crashing.
Can someone help!?!