How can we set java.library.path in Eclipse?

+28 votes

How can I set the java.library.path for a whole Eclipse Project?

Jul 3, 2018 in Java by Sushmita
• 6,850 points
1,584 views

3 answers to this question.

+2 votes
Best answer

Go into the library settings for your projects and, for each jar/etc that requires a native library, expand it in the Libraries tab. In the tree view there, each library has items for source/javadoc and native library locations.

Specifically: select Project, right click -> Properties / Java Build Path / Libraries tab, select a .jar, expand it, select Native library location, click Edit, folder chooser dialog will appear)

Messing with the library path on the command line should be your last ditch effort, because you might break something that is already properly set by eclipse.

Native library location

answered Jul 3, 2018 by sharth
• 3,320 points

selected Aug 2, 2018 by Omkar
0 votes

If you have single native libs in your project, there is another way you can do it. 

Go to Project properties->Java Build Path->Source. You'll find a list of source-folders. Each entry under the the Source tab has Native library locations. It supports paths within the workspace and it will make Eclipse add it to your java.library.path.

answered Aug 2, 2018 by Omkar
• 67,290 points
0 votes

There are several ways to set the java.library.path property:

  • Through the command line or terminal: Using the terminal (Linux or Mac) or the command prompt (Windows), we can execute the following command, in order to execute our Java application:

    1 java -Djava.library.path=<path_to_dll> <main_class>

    where the path_to_dll argument must be replaced with the path of the required library.

  • Through Java source code: Inside an application’s code we can set the java.library.path using the following code snippet:
    1 System.setProperty(“java.library.path”, “/path/to/library”);
answered Aug 2, 2018 by Priyaj
• 56,200 points

Related Questions In Java

0 votes
4 answers

How can we compare dates in java?

public static String daysBetween(String day1, String day2) ...READ MORE

answered Sep 5, 2018 in Java by Sushmita
• 6,850 points
37 views
0 votes
1 answer

How can we get file extension in Java?

To get the file extension, we can ...READ MORE

answered May 8, 2018 in Java by parth295
• 4,600 points
269 views
0 votes
2 answers

How can we remove an element from an array in Java?

You can use ArrayUtils class remove method which ...READ MORE

answered May 24, 2018 in Java by UshaK
95 views
0 votes
1 answer

How can we resolve ClassNotFoundException in Java?

Your classpath is broken. Depending on how you ...READ MORE

answered May 22, 2018 in Java by Akrati
• 3,150 points
48 views
+1 vote
10 answers

How to import a jar file in Eclipse?

Go to your project right click and ...READ MORE

answered Dec 10, 2018 in Java by Hola77
40,457 views
0 votes
1 answer

How can we import javax.servlet API in Eclipse?

Before installing Eclipse, ensure that you are ...READ MORE

answered Jun 7, 2018 in Java by parth295
• 4,600 points
368 views
0 votes
2 answers
0 votes
1 answer

Which is the best GUI designer for Eclipse?

Windows Builder Pro is the best GUI ...READ MORE

answered May 21, 2018 in Java by Akrati
• 3,150 points
178 views
0 votes
4 answers

How can we define global variables in java?

class G { static String globalVar ...READ MORE

answered Jan 29 in Java by zemiak
3,036 views
0 votes
3 answers

How can we use java.String.format in Scala?

String aString = "world"; int aInt = 20; String.format("Hello, ...READ MORE

answered Aug 29, 2018 in Java by Daisy
• 8,040 points
199 views