jni4net - java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I
jni4net - java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I
我找到了这个库,我非常喜欢它...但是我无法开始使用它...我不知道我做错了什么,但是有人可以帮助我吗?
我已阅读 wiki 和环境设置。我正在尝试在 Java 调用 C# 中做一个简单的 hello world。
但是我收到这个错误:
java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I
这是我在 Eclipse 中的文件夹设置:https://cloud.githubusercontent.com/assets/6147142/8265327/e2419670-16cd-11e5-85bd-dae9ea275186.png
这是我的主要内容 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();
}
}
这是完整的堆栈跟踪:
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
我不知道为什么,但是我在 jdk7 上发生了这个错误。所以我回到 jni4net 0.8.3 版本,一切都很好!对不起。但是由于我正在使用另一个供应商应用程序,我还不能更新到 jdk8。
我找到了这个库,我非常喜欢它...但是我无法开始使用它...我不知道我做错了什么,但是有人可以帮助我吗?
我已阅读 wiki 和环境设置。我正在尝试在 Java 调用 C# 中做一个简单的 hello world。
但是我收到这个错误:
java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I
这是我在 Eclipse 中的文件夹设置:https://cloud.githubusercontent.com/assets/6147142/8265327/e2419670-16cd-11e5-85bd-dae9ea275186.png
这是我的主要内容 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();
}
}
这是完整的堆栈跟踪:
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
我不知道为什么,但是我在 jdk7 上发生了这个错误。所以我回到 jni4net 0.8.3 版本,一切都很好!对不起。但是由于我正在使用另一个供应商应用程序,我还不能更新到 jdk8。