0

I have a dll file which I am trying to call using my java program.

My java program and dll file both in the same folder C://JNI_project

My dll name is JNITest.dll

My java program is as follows:

public class JNITest {
   static{


      System.loadLibrary("JNITest");
   }

     public static void main(String[] args) {
     JNITest test=new JNITest();
      //test.greet();
   }
}

I executed the program in cmd as follows:

C:\JNI_project>javac JNITest.java

C:\JNI_project>java JNITest
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: key can't be empty
        at java.lang.System.checkKey(Unknown Source)
        at java.lang.System.getProperty(Unknown Source)
        at JNITest.<clinit>(JNITest.java:5)

I am getting errors on run time. Please guide me to solve this.

johnson
  • 117
  • 3
  • 12
  • `System.getProperty("")` is your problem, and the exception message is pretty much telling you that too. You need to pass in a non-empty value to that method call. – JonK Oct 29 '15 at 15:58
  • @JonK can you suggest me what should I pass? I am refering this link http://stackoverflow.com/questions/14286647/trying-to-use-dll-from-java-jna-unable-to-load-library-exception – johnson Oct 29 '15 at 16:00
  • Well I'm not sure why you're trying to set a property to the value of another property. Do you even need the call to `getProperty` in the first place? – JonK Oct 29 '15 at 16:03
  • I have changed the program like this but still i am getting error at run time public class JNITest { static{ System.loadLibrary("JNITest"); } public static void main(String[] args) { JNITest test=new JNITest(); //test.greet(); } } – johnson Oct 29 '15 at 16:09

0 Answers0