How to set the java.library.path from Eclipse

后端 未结 16 2415
陌清茗
陌清茗 2020-11-22 05:36

How can I set the java.library.path for a whole Eclipse Project? I\'m using a Java library that relies on OS specific files and need to find a .dll/

相关标签:
16条回答
  • 2020-11-22 06:19

    I'm using Mac OS X Yosemite and Netbeans 8.02, I got the same error and the simple solution I have found is like above, this is useful when you need to include native library in the project. So do the next for Netbeans:

    1.- Right click on the Project
    2.- Properties
    3.- Click on RUN
    4.- VM Options: java -Djava.library.path="your_path"
    5.- for example in my case: java -Djava.library.path=</Users/Lexynux/NetBeansProjects/NAO/libs>
    6.- Ok
    

    I hope it could be useful for someone. The link where I found the solution is here: java.library.path – What is it and how to use

    0 讨论(0)
  • 2020-11-22 06:20

    For a given application launch, you can do it as jim says.

    If you want to set it for the entire workspace, you can also set it under

    Window->
      Preferences->
        Java->
          Installed JREs
    

    Each JRE has a "Default VM arguments" (which I believe are completely ignored if any VM args are set for a run configuration.)

    You could even set up different JRE/JDKs with different parameters and have some projects use one, other projects use another.

    0 讨论(0)
  • 2020-11-22 06:20

    Just add the *.dll files to your c:/windows

    You can get the java.library.path from the follow codes:and then add you dll files under any path of you get

    import java.util.logging.Logger;
    
    public class Test {
    
    
        static Logger logger = Logger.getLogger(Test.class.getName());
        public static void main(String[] args) {
        logger.info(System.getProperty("java.library.path"));
        }
    }
    
    0 讨论(0)
  • 2020-11-22 06:25

    Click Run
    Click Debug ...
    New Java Application
    Click Arguments tab
    in the 2nd box (VM Arguments) add the -D entry

    -Xdebug -verbose:gc -Xbootclasspath/p:jar/vbjorb.jar;jar/oracle9.jar;classes;jar/mq.jar;jar/xml4j.jar -classpath -DORBInitRef=NameService=iioploc://10.101.2.94:8092/NameService  
    

    etc...

    0 讨论(0)
  • 2020-11-22 06:27

    If you are adding it as a VM argument, make sure you prefix it with -D:

    -Djava.library.path=blahblahblah...
    
    0 讨论(0)
  • 2020-11-22 06:27

    Except the way described in the approved answer, there's another way if you have single native libs in your project.

    • in Project properties->Java Build Path->Tab "Source" there's a list of your source-folders
    • For each entry, there's "Native library locations", which also supports paths within the workspace.
    • This will make Eclipse add it to your java.library.path.
    0 讨论(0)
提交回复
热议问题