Working with GPIB interfaces

GPIB is a standard interface when working with basic electronics devices. These devices are common in the testing environment and therefore sometime should be integrated into the JSystem. The target of this post is to explain how this type of integration should be done.

First you need to understand that from standard Java code it’s impossible to access GPIB interface. The interface requires writing/reading to/from system registers, something that is foreign to Java (due to platform independence architecture). The only way to access platform specific resources is the usage of JNI mechanism.

In order to integrate JSystem and GPIB we will use an already existing module that allows interaction with that kind of interface through JNI. The package is also an open source project called “jpib”. You can download this package from the following location: The file that you will download will be

Here is what you need to do:
1. Unpack the content of the file into some directory
2. Put jpib.dll into C:\Windows\system32
3. Put jpib.jar into c:\jsystem\runner\thirparty\lib
4. Put into c:\Program Files\Java\\jre\lib

Once this is done you are ready to work with this module.

Here is a simple code that will do the work (this example is for Agilent DMM device):

private GPIBDeviceIdentifier deviceIdentifier;
private GPIBDevice gpibDevice; 
private Enumeration devicesList;

private void connect()throws Exception {
	if (connected)
	try {
		devicesList = GPIBDeviceIdentifier.getDevices();
		while (devicesList.hasMoreElements()){
			deviceIdentifier = (GPIBDeviceIdentifier) devicesList.nextElement();
			if (deviceIdentifier.getAddress() == gpibAddress){ 
				gpibDevice =;
	} catch(Exception e){
		throw new Exception("Unable to find GPIB connection: " + e.getMessage());
	} finally {
		if (gpibDevice == null) {
			throw new Exception("Unable to open found device: " + deviceIdentifier.toString()); 
	connected = true;

 * Write command to DMM
 * @param command
 * @throws Exception
public void writeCommand(String command) throws Exception{

 * Send command to the DMM 
 * @param command
 * @return String - the command or query result
 * @throws Exception
public String sendCommand(String command) throws Exception{
	String temp = gpibDevice.sendCommand(command);
	return temp;

public double readDcVoltage() throws Exception {
	return Double.parseDouble(sendCommand("MEASure:VOLTage:DC? 10, 0.003"));

Please note that this code is a part of a system object and some parameters (like the gpibAddress) should come from the SUT configuration.

Fork me on GitHub