Java API for NI Drivers

Updated Sep 28, 2022

Reported In

Driver

  • NI-DAQmx
  • NI-VISA
  • NI-488.2
  • NI-DMM

Issue Details

  • How can I access NI drivers from Java? 
  • Can I call DAQmx functions from a Java application?
  • Can I use Java with NI DMM?

Solution

NI does not currently provide language interfaces for Java. It is possible, however, to access NI drivers by making calls to the driver DLL by making a wrapper using the Java Native Interface (JNI). Sun Java includes the JNI which allows calls to be made to C DLLs from Java. This wrapper DLL has to comply with JNI naming requirements, and perform the conversion from Java to C data types.

There are some considerations to be made when doing this. For example, when working with the error cluster, a separate class would be required to handle the data that is contained in an error. Another example is the waveform datatype, which in LabVIEW is a cluster of multiple elements and attributes. These LabVIEW specific data types need to be converted into a data type that Java understands to use NI drivers in a Java environment.