birgersp
birgersp

Reputation: 4956

Set java.library.path when running a test in Netbeans

To set the java.library.path to run my Java application, I just change the "VM Options:" value in my project properties like I've shown here:

How to set java library path in Netbeans

However, the java.library.path is not set when running a test. How can I set it for testing?

Thanks

Upvotes: 2

Views: 1272

Answers (2)

Petr
Petr

Reputation: 118

In Netbeans 8.2 my generated project.properties file contains this comment:

# To set system properties for unit tests define test-sys-prop.name=value

So you can edit the file and add there:

test-sys-prop.java.library.path=/path/to/your/native/libs

I tested the value with the System.getProperty("java.library.path") and it seemed to work.

But anyway if you fail with setting the java.library.path property you can always use the PATH environemt variable on Windows systems or LD_LIBRARY_PATH on Unix-like systems.

Hope this will help. Petr

Upvotes: 2

Ted
Ted

Reputation: 3260

Not sure if this will help, but what I needed was to be able to do this in a Netbeans Platform RPC project. Getting my unit test to recognize external dll libraries would not work with the normal VM Options dialog because those run settings are controlled differently in RPC projects. The location of the external libraries have to be in special release folders:

release/modules/lib/amd64 for x64 libraries and release/modules/lib/x86 for x86 libraries.

To tell the unit tests which folders I was using I set the project properties like:

Project Properties

My reference for learning this was here:

Netbeans Formum Topic 13801

Upvotes: 1

Related Questions