Installing Java API for GPIB devices in eclipse

1.1k views Asked by At

This is probably a trivial question, but I am having trouble installing a Java API called JPIB_Windows into eclipse which should allow me to control external devices connected via GPIB.

This is the contents of the folder that I downloaded. enter image description here

I created a new project in Eclipse, right clicked the project and went to build path -> configure build path.

I then clicked on add external libraries and added the JPIB.jar file. The file was added, but I am still not able to use the classes in the API.

Is there something else that I need to do to be able to use the API? Is there a better way of importing this API into my project?

1

There are 1 answers

2
flaz14 On

You jar file is installed correctly. JPIB (and many other Java libraries) is just wrapper for low-level routines. So it is mandatory to load corresponding native libraries before using Java classes.

In Eclipse go to the Run > Run Configurations... > Arguments tab, select configuration for, perhaps, main method. Then specify in VM arguments field:

-Djava.library.path=C:\path\to\jpib\dll

Then add at the beginning of main() the following line:

System.loadLibrary("jpib_32");

Then run already edited configuration. Everything should be OK. But in case of failure you can examine path to DLL:

System.out.println("Libary path: " + System.getProperty("java.library.path"));

Also working directory can be specified in the same tab, avoiding absolute path, but for the first time absolute path is simple and less error-prone.

Also note that Java may not recognize Windows-specific issues (missing drivers, insufficient user privileges, wrong DLL version) and will report about general error.