简体   繁体   中英

How do I have to tell Java where to find native libraries?

I am trying to figure out if my Java is misbehaving or not.

I have cleaned and built my Java project in NetBeans and then tried to run the program on the command line with the following command:

java -jar ProjectName.jar

I get the following error:

The library x.dll could not be loaded by Windows. Make sure that the library is in your Path environment variable. Exception in thread "main" java.lang.ExceptionInInitializerError.

Does this mean that for every project with library files in the dist folder, I need to include it in the path environment variable? This sounds awfully troublesome and I would have thought that Java would be smart enough to look inside the lib folder for these library files. Or do I need to configure something else in the IDE to do this?

java -Djava.library.path=<path where dll located> -jar ProjectName.jar

You need to include the dll or jar in the classpath when you launch the application / Java.

http://download.oracle.com/javase/7/docs/technotes/tools/windows/java.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM