2015-06-20 78 views
0

我找到了這個庫,我非常喜歡它...但我無法開始使用它...我不知道我在做什麼錯,但任何人都可以幫助我嗎?jni4net - java.lang.UnsatisfiedLinkError:net.sf.jni4net.Bridge.initDotNet()I

我已閱讀wiki和環境設置。我正在嘗試在Java中調用一個簡單的hello world來調用C#。

但我收到此錯誤:

java.lang.UnsatisfiedLinkError: net.sf.jni4net.Bridge.initDotNet()I

這裏的在Eclipse我的文件夾設置:https://cloud.githubusercontent.com/assets/6147142/8265327/e2419670-16cd-11e5-85bd-dae9ea275186.png

這裏是我的主類:

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 

回答

0

我不知道爲什麼,但這個錯誤發生在我身上的jdk7上。所以我回到版本jni4net 0.8.3,一切都很好!對不起。但是由於我正在使用的另一個供應商應用程序,我無法更新到jdk8。

相關問題