« Close

Datasheets and User Guides

App Notes

Software & Driver

 

Java for UD - Windows

Java wrappers and examples for the Windows UD library. The Windows UD library is the high-level Windows library/driver for the LabJack U3, U6 and UE9. For other LabJack devices, go to the Software page.

 

Java_LJUD_2015_04_27.zip

The latest and recommended Java wrapper and examples for the Windows UD driver. Requires JNA and supports 32 and 64-bit Java and UD driver. Refer to the download's README.txt for requirements, compile/run instructions, documentation and license information.

 

Old Java_LJUD.zip

The old Java wrapper and examples which are no longer updated. Uses a JNI dll and only supports 32-bit Java and UD driver. Refer to the text file in the zip for more information.

 

14 comments

I am looking for code that will let me use the labjack with BlueJ java. Nothing too complicated like the Java code in the download above. Do you have anything that can help me as I don't have experience with using other Java IDEs or Python, thanks.

If you want to use the UD driver, or any other dll, and Java in general, you will need something like we provide in the download since Java requires JNI (Java Native Interface).  Also, the UD driver this Java interface wraps is our high level driver, and is one of the easiest ways to interface with our UD devices (UE9/U3/U6).

I've never used BlueJ Java before, but is there no way to load the dll in code and add the classpath to the jar file?  An alternative to using the jar file in your project would be to extract the class files out of the jar and add them to your project.  Note to keep the directory structure of the LJUDJava classes in your project (com\labjack\labjackud).  You can extract the classes with the "jar xf LJUDJava.jar" command.

I am running into a runtime unsatisfied link symbols error when running a Java program connecting to the U3 on 3.25 of the UD.

The call to LJUD.GetDriverVersion() is failing - it looks like the dll will not support this call anymore

it used to work ok.

Has anyone had success with Java connections recently?

 

I tested with the latest UD driver 3.32 and didn't see problems. Do the examples run for you?

Note that the wrapper currently only supports 32-bit Java, so the 32-bit UD driver (labjackud.dll) needs to be installed in the "C:\Windows\System32\" directory on 32-bit Windows or "C:\Windows\SysWOW64" on 64-bit Windows. The UD installer should have taken care of that.

When will a 64 bit Java and UD driver be released? I have the java program working perfectly on a 32 bit system but will not work on a 64 bit system.

We are currently working on this at the moment.  We are changing our Java support to use JNA which allows one set of Java code to work in both 32-bit and 64-bit environments.  We are still working on finalizing how we want things but are sending some samples to people for feedback.  If you would like more info or for some preview code please send us an email at [email protected].

I'm interested in this as well. Just posting this so I can be notified when this is available.

Have you guys made progress on the 64 bit JNA library yet?

I have a bunch of U6 pros and code running well in 32 bit java but the programs have a lot going on and I'd like to update to 64 bit for the extra memory capacity.

Just wanted to let you know i like your products and they work well for me. If you get the 64 bit library worked out I'll be buying more.

If you wanted to do something else awesome I'd love to see a accessory board that is setup for direct measurement of Strain Gauge signals at 24 bit.

I've been wanting to make an attempt at a prototype board with the AD7710 to simplify/expand my load cell and other strain gauge measurements but never get the chance. :-)

 

Thanks,

Chris

 

If you send us an email we can send the current JNA example which is 64-bit compatible. Unfortunately we haven't made much progress since our last post, but since you brought it to our attention again I can look into making a UD Java interface using JNA. It would be comparable to our LJM driver's Java interface, but will use the UD functions. Note that it will use some JNA data types for parameters which will differ than the JNI interface we currently provide. I'll post again when that's available.

If you are looking into getting additional LabJacks we do have the LabJack T7. It has cross-platform 32-bit and 64-bit Java support:

http://labjack.com/t7

http://labjack.com/support/ljm/examples/java

The new Windows UD Java wrapper and examples using JNA with 32 and 64-bit support is now available for download on this page.

Thanks a ton. This works like a great on Windows 64. What would it take to get this driver ported to Linux?

For the newly released Java LJUD wrapper to work on Linux would require us to port the Windows UD library/driver and update the Java wrapper. The UD library/driver is for Windows only and is closed source. Currently we have no plans to port the UD library to other operating systems. For Linux and UD devices (U3, U6 and UE9), a different Java wrapper would be needed as the UD and Exodriver (Linux/Mac OS X library) functions are different. Linux user's will need to use their own JNI or JNA (recommended way) code with the Exodriver and its functions as we currently do not provide a Linux Java wrapper.

The only cross-platform library (Windows, Linux, Mac OS X) with a Java wrapper that we provide is the LJM driver. At this time the LJM library only supports the Digit (didn't mention it in a previous comment) and T7, and will support future devices.

Yeah, I've looked at the exodriver, which is why I asked about the UD driver linux port.  :)  Although, I'm wondering if the LJM library is what I should have utilized instead of the Windows UD driver. All I'm really after is the following methods below. Out of those methods, it looks like the ePut/eGet are the only two methods that don't have direct replacements in the LJM library. Do you have some examples of how I would use the LJM library to get the equivalent functionality as the ePut/eGet methods gave me?

int OpenLabJack(int DeviceType, int ConnectionType, String Address, int FirstFound, IntByReference Handle );

int ePut(int Handle, int IOType, int Channel, double Value, int x1);

int eGet(int Handle, int IOType, int Channel, DoubleByReference pValue, int x1);

void ErrorToString(int ErrorCode, ByteByReference pString);

int ListAll(int DeviceType, int ConnectionType, IntByReference pNumFound, IntByReference pSerialNumbers, IntByReference pIDs, DoubleByReference pAddresses);

For reading and writing a single value using the LJM library there are the eReadName/Address and eWriteName/Address functions. With these functions you specify the Modbus Name (a string) or address of what you want to read/write on the device. For example, these UD calls to read from AIN1 and set DAC1:

eGet(handle, LJ_ioGET_AIN, 1, &value, 0); //Read from AIN1
ePut(handle, LJ_ioPUT_DAC, 1, 2.50, 0); //Set DAC1 to 2.50 V

look like this in the LJM driver (using name functions):

LJM_eReadName(handle, "AIN1", &value); //Read from AIN1
LJM_eWriteName(handle, "DAC1", 2.50); //Set DAC1 to 2.50 V

Here are the documentation pages for the function calls with the same functionality as the functions you listed:

LJM_OpenS
LJM_eWriteName
LJM_eReadName
LJM_ErrorToString
LJM_ListAllS

Here is the LJM User's Guide with more documentation and functions:

http://labjack.com/support/ljm/users-guide

Here are the LJM examples for a variety of languages, including Java examples demonstrating LJM_eWriteName and LJM_eReadName:

http://labjack.com/support/ljm/examples