Java 7 in Kubernetes jdk8 "server"
Closed, ResolvedPublic

Description

I am trying to run an executable Java JAR compiled with Java 8.

I start the Kubernetes jdk8 shell:

tools.replacer@tools-bastion-02:~$ webservice --backend=kubernetes jdk8 shell
If you don't see a command prompt, try pressing enter.
tools.replacer@interactive:~$ 
tools.replacer@interactive:~$ java -version
java version "1.7.0_181"
OpenJDK Runtime Environment (IcedTea 2.6.14) (7u181-2.6.14-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.181-b01, mixed mode)

Is it normal that in the jdk8 shell the Java version is 7 ?

On the other hand, Maven and Java compiler use the JDK8:

tools.replacer@interactive:~$ mvn -v
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_171, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.0-0.bpo.6-amd64", arch: "amd64", family: "unix"
tools.replacer@interactive:~$ javac -version
javac 1.8.0_171

Thanks for your help,

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 29 2018, 9:14 AM
$ webservice --backend=kubernetes jdk8 shell
If you don't see a command prompt, try pressing enter.
tools.bd808-test2@interactive:~$
tools.bd808-test2@interactive:~$ which java
/usr/bin/java
tools.bd808-test2@interactive:~$ file /usr/bin/java
/usr/bin/java: symbolic link to /etc/alternatives/java
tools.bd808-test2@interactive:~$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
tools.bd808-test2@interactive:~$ ls /usr/lib/jvm/
default-java              java-1.8.0-openjdk-amd64  java-8-openjdk-amd64
java-1.7.0-openjdk-amd64  java-7-openjdk-amd64

In the Dockerfile for the jdk8 containers, we are installing the openjdk-8-jdk package from jessie-backports, but we are not explicitly doing anything to update the alternatives symlinks to point to that runtime as the system default. I'm not sure if fixing this is as simple as adding a call to update-alternatives --auto java or if we have to do something fancier.

Change 463877 had a related patch set uploaded (by BryanDavis; owner: Bryan Davis):
[operations/docker-images/toollabs-images@master] jdk8: make java-1.8.0-openjdk-amd64 default

https://gerrit.wikimedia.org/r/463877

Change 463877 merged by GTirloni:
[operations/docker-images/toollabs-images@master] jdk8: Switch base image to Stretch

https://gerrit.wikimedia.org/r/463877

Change 476927 had a related patch set uploaded (by GTirloni; owner: Giovanni Tirloni):
[operations/docker-images/toollabs-images@master] jdk8: Switch base image to Stretch

https://gerrit.wikimedia.org/r/476927

Change 476927 merged by GTirloni:
[operations/docker-images/toollabs-images@master] jdk8: Switch base image to Stretch

https://gerrit.wikimedia.org/r/476927

Change 476975 had a related patch set uploaded (by GTirloni; owner: Giovanni Tirloni):
[operations/docker-images/toollabs-images@master] jdk8: Try to finally fix the invalid apt parameter

https://gerrit.wikimedia.org/r/476975

Change 476975 merged by GTirloni:
[operations/docker-images/toollabs-images@master] jdk8: Try to finally fix the invalid apt parameter

https://gerrit.wikimedia.org/r/476975

Mentioned in SAL (#wikimedia-cloud) [2018-11-30T22:18:04Z] <gtirloni> Pushed new jdk8 docker image based on stretch (T205774)

@Benjavalero I've just pushed a new docker image with @bd808's changes. I'm closing this ticket but feel free to re-open if your issue is not solved by that.

$ docker run --rm -ti docker-registry.tools.wmflabs.org/toollabs-jdk8-web /bin/sh
# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
GTirloni closed this task as Resolved.Fri, Nov 30, 10:24 PM
GTirloni triaged this task as Normal priority.