Update ZWave binding with new/updated device xml

It had been a while since I had used this method and going through the example I had a problem with “jar command not found”. Since Java 8 (used in OH2), not all versions of Java include the “jar” class that is used to update the xml. This section should help, but there are lots of variations and they can’t all be covered. This a little more advanced using the update-alternatives command

  1. First find the configured version(s) of java. If there is more than one, openHAB is using the “auto” or highest priority. Also navigate to /usr/lib/jvm directory and check for installed, but not configured java versions and check the /bin file of each one for a “jar” file.
 CHECK INSTALLED JAVA VERSION(S) & LOCATION
openhabian@openhab:~ $ sudo update-alternatives --list java
/usr/lib/jvm/java-17-openjdk-armhf/bin/java
CHECK FOR JAR CLASS (TWO WAYS)
openhabian@openhab:~$ update-alternatives --list jar
update-alternatives: error: no alternatives for jar
OR (CHECK OTHER JAVA VERSIONS IN THIS DIRECTORY - IF ANY)
openhabian@openhab:~ $ cd /usr/lib/jvm
openhabian@openhab:/usr/lib/jvm $ dir
default-java  java-1.11.0-openjdk-armhf  java-1.17.0-openjdk-armhf  java-11-openjdk-armhf  java-17-openjdk-armhf  zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf
openhabian@openhab:~ $ cd /usr/lib/jvm/java-17-openjdk-armhf/bin
openhabian@openhab:/usr/lib/jvm/java-17-openjdk-armhf/bin $ dir
java  jpackage  keytool  rmiregistry
openhabian@openhab:/usr/lib/jvm $ cd /usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin
openhabian@openhab:/usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin $ dir
jar        java   javadoc  jcmd      jdb        jdeps  jhsdb   jinfo  jmap  jpackage  jrunscript  jstack  jstatd   rmiregistry
jarsigner  javac  javap    jconsole  jdeprscan  jfr    jimage  jlink  jmod  jps       jshell      jstat   keytool  serialver

a) If the only java version is either java-17-openjdk-armhf or java-11-openjdk-armhf, on the command line; sudo apt-get install openjdk-17-jdk-headless (or -11- on some older OH3 installations) EDIT: or java-21 jdk. The key issue is the JDK has the jar command, not the JRE.

INSTALL JAVA JDK WITH JAR CLASS (IF NEEDED)
openhabian@openhab:~ $ sudo apt-get install openjdk-17-jdk-headless
<SNIP> PROGRESS REPORTS
The following NEW packages will be installed:
  openjdk-17-jdk-headless
<SNIP> PROGRESS REPORTS
Setting up openjdk-17-jdk-headless:armhf (17.0.6+10-1~deb11u1+rpt1) ...
KEY UPDATE
update-alternatives: using /usr/lib/jvm/java-17-openjdk-armhf/bin/jar to provide /usr/bin/jar (jar) in auto mode
<SNIP> OTHER UPDATES
openhabian@openhab:~ $  cd /usr/lib/jvm/java-17-openjdk-armhf/bin (CHECK)
openhabian@openhab:/usr/lib/jvm/java-17-openjdk-armhf/bin $ dir
jar        java   javadoc  jcmd  jdeprscan  jfr    jimage  jlink  jmod      jps         jshell  jstat   keytool      serialver
jarsigner  javac  javap    jdb   jdeps      jhsdb  jinfo   jmap   jpackage  jrunscript  jstack  jstatd  rmiregistry

b) If there is another java version installed, but not configured and it contains the jar class add it as shown below. (I had previously used Zulu Java and it did contain the jar file-see above). Note I had already upgraded to the 17-jdk package so have two versions at this point.

ADD JAR FROM ANOTHER JAVA
openhabian@openhab:/ $ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin/jar 1111
openhabian@openhab:/ $ sudo update-alternatives --config jar
There are 2 choices for the alternative jar (providing /usr/bin/jar).

  Selection    Path                                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-armhf/bin/jar                       1711      auto mode
  1            /usr/lib/jvm/java-17-openjdk-armhf/bin/jar                       1711      manual mode
  2            /usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin/jar   1111      manual mode

Press <enter> to keep the current choice[*], or type selection number:

(note: I left the zulu java as lower priority to not interfere with Openhab.)

Hopefully either the jdk upgrade or configuring an existing java installation will allow the jar upgrade to proceed for your ZWave device xml.

5 Likes