Skip to main content


A scale example program for Datalogic JavaPOS

LiveWeightExample outputs live weight data until you press enter to exit. LiveWeightExample runs with Datalogic JavaPOS. The latest release of JavaPOS can be downloaded from the Datalogic website here.

The LiveWeightExample repository contains the source and shell scripts to run the LiveWeightExample.jar you build. The repository also has a NetBeans IDE (Integrated Development Environment) project to perform the build. Other IDEs can be used.

Steps to build and run LiveWeightExample.jar:

  1. Install Datalogic JavaPOS. This install includes the JavaPOSTest program.

  2. Make sure Datalogic JavaPOS runs with your scale. With your scale and JavaPOSTest do an Open, Claim, Enable and Read Weight. With nothing on the scale it should read 0.000. Put something on the scale. Press Read Weight again. It should read a positive number.

  3. Clone or download the LiveWeightExample repository.

  4. Build LiveWeightExample.jar. This was originally done with the following. Variations near these should work.

    • Apache NetBeans 11.0
    • Java jdk1.8.0_231
    • The LiveWeightExample project in NetBeans is a Java with Ant, Java Application project. The build uses a library of the JavaPOS's .jar files. These .jar files are in the JavaPOS install's root directory where it has its JavaPOS.jar and its SupportJars directory. Create this library via NetBeans -> Tools -> Libraries. Add the library to the LiveWeightExample NetBeans project via its Properties -> Libraries -> Classpath + -> Add Library...

    Another variation here builds LiveWeightExample.jar without requiring the Apache NetBeans 11.0 Integrated Development Environment (IDE). It instead builds with the included script BuildLiveWeightExample.cmd or These scripts explicitly use the Java JDK's javac and jar programs and require no intermediary IDE. Related "inside" scripts show what is inside LiveWeightExample.jar and Datalogic's JavaPOS.

  5. Update the jpos.xml of your installed JavaPOS to include a <JposEntry logicalName="JavaPOSScaleDevice"> entry for your scale and interface. This entry is a copy of the entry you used with JavaPOSTest above. The only difference is the logicalName is changed to JavaPOSScaleDevice.

  6. With LiveWeightExample.jar make your scale weigh. Use the appropriate LiveWeightExample script, .cmd or .sh. With nothing on the scale it should output Zero Weight: 0. With something on the scale it should output Stable Weight: (number) (units). When the scale weight is changed and before the scale settles, it should output Unstable Weight: --.--.

  7. The following image shows a successful run.