LiveWeightExample
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 LiveWeightExample.java 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:
-
Install Datalogic JavaPOS. This install includes the JavaPOSTest program.
-
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.
-
Clone or download the LiveWeightExample repository.
-
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 BuildLiveWeightExample.sh. 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.
-
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. -
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 outputStable Weight: (number) (units)
. When the scale weight is changed and before the scale settles, it should outputUnstable Weight: --.--
. -
The following image shows a successful run.
- Windows
- Linux