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,820 points
1,126 views

3 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+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,310 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
• 65,850 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,120 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,820 points
25 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,590 points
185 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
66 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
26 views
0 votes
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
19,966 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,590 points
267 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
118 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
1,347 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,020 points
143 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.