I've found this library and I loved it so much... But I can't start using it... I don't know what I'm doing wrong, but can anyone help me?
I've read the wiki and environment setup. And I'm trying to do a simple hello world in Java calling C#.
But I'm receiving this error:
java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I
Here's my Folder setup in Eclipse: https://cloud.githubusercontent.com/assets/6147142/8265327/e2419670-16cd-11e5-85bd-dae9ea275186.png
Here's my Main Class:
package testJni4net;
import java.io.IOException;
import java.lang.String;
import net.sf.jni4net.Bridge;
import system.*;
import system.Object;
import system.io.TextWriter;
import system.collections.IDictionary;
import system.collections.IEnumerator;
public class Teste1 {
public static void main(String[] args) throws IOException {
// create bridge, with default setup
// it will lookup jni4net.n.dll next to jni4net.j.jar
Bridge.setVerbose(true);
Bridge.init();
// here you go!
Console.WriteLine("Hello .NET world!\n");
// OK, simple hello is boring, let's play with System.Environment
// they are Hashtable realy
final IDictionary variables = system.Environment
.GetEnvironmentVariables();
// let's enumerate all keys
final IEnumerator keys = variables.getKeys().GetEnumerator();
while (keys.MoveNext()) {
// there hash table is not generic and returns system.Object
// but we know is should be system.String, so we could cast
final system.String key = (system.String) keys.getCurrent();
Console.Write(key);
// this is automatic conversion of JVM string to system.String
Console.Write(" : ");
// we use the hashtable
Object value = variables.getItem(key);
// and this is JVM toString() redirected to CLR ToString() method
String valueToString = value.toString();
Console.WriteLine(valueToString);
}
// Console output is really TextWriter on stream
final TextWriter writer = Console.getOut();
writer.Flush();
}
}
And here's the full stack trace:
Can't initialize jni4net Bridgenet.sf.jni4net.Bridge.initDotNet()I
Exception in thread "main" net.sf.jni4net.inj.INJException: Can't initialize jni4net Bridge
at net.sf.jni4net.CLRLoader.init(CLRLoader.java:45)
at net.sf.jni4net.Bridge.init(Bridge.java:35)
at net.sf.jni4net.Bridge.init(Bridge.java:31)
at testJni4net.Teste1.main(Teste1.java:19)
Caused by: java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I
at net.sf.jni4net.Bridge.initDotNet(Native Method)
at net.sf.jni4net.CLRLoader.init(CLRLoader.java:37)
... 3 more
I don't know why but this error happened to me on jdk7. So I back to version jni4net 0.8.3 and everything is fine! Sorry for that. But I can't update yet to jdk8 because of another vendor applications that I'm using.