FAQ  •  Register  •  Login

HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS

<<

skiaccianos

User avatar

Streaming enthusiast

Posts: 28

Joined: Thu Nov 26, 2015 2:06 pm

Location: Terni, Umbria, Italia

Post Fri Apr 27, 2018 8:14 am

HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS

Hi all,
Ubuntu Bionic has been released yesterday and ships a new default java (openjdk-11-jre/bionic,now 10.0.1+10-3ubuntu1): Serviio is not working with this release, so you have to install jre 8 alongside the 11 and make it the default. Like this:

  Code:
matteo@TMP258-MG:~$ sudo apt list --installed |grep jre                                                                                                                                       
                                                                                                                                                                                               
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.                                                                                                                 
                                                                                                                                                                                               
default-jre/bionic,now 2:1.10-63ubuntu1~02 amd64 [installato, automatico]
default-jre-headless/bionic,now 2:1.10-63ubuntu1~02 amd64 [installato, automatico]
openjdk-11-jre/bionic,now 10.0.1+10-3ubuntu1 amd64 [installato, automatico]
openjdk-11-jre-headless/bionic,now 10.0.1+10-3ubuntu1 amd64 [installato, automatico]
openjdk-8-jre/bionic,now 8u162-b12-1 amd64 [installato]                                              <<<<< apt get install this one
openjdk-8-jre-headless/bionic,now 8u162-b12-1 amd64 [installato, automatico]
matteo@TMP258-MG:~$ sudo update-alternatives --config java
Sono disponibili 2 scelte per l'alternativa java (che fornisce /usr/bin/java).

  Selezione    Percorso                                        Priorità  Stato
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      modalità automatica
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      modalità manuale
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      modalità manuale

Press <enter> to keep the current choice[*], or type selection number: 2
matteo@TMP258-MG:~$


Regards
Running Serviio - for several years now - on Debian and Win boxes.
R850R biker, sysadmin & DBA, FOSS and Linux enthusiast (desktop_is_home_dir)
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Fri Apr 27, 2018 8:53 am

Re: HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS

how does it fail with Java 11?

There is support for Java 9 in serviio.sh

  Code:
# Check if we are using Java9
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
case "$JAVA_VERSION" in
    \9*) JAVA9_OPTS="--add-modules java.xml.ws,jdk.unsupported" ;;
    *) JAVA9_OPTS="" ;;
esac


I assume it'd have to be updated for Java 10/11 and use the same behaviour as for Java 9 (ie add the --add-module opts)
<<

skiaccianos

User avatar

Streaming enthusiast

Posts: 28

Joined: Thu Nov 26, 2015 2:06 pm

Location: Terni, Umbria, Italia

Post Fri Apr 27, 2018 10:14 pm

Re: HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS

Hi zip,
this is how it fails

  Code:
matteo@TMP258-MG:~$ sudo update-alternatives --config java
Sono disponibili 2 scelte per l'alternativa java (che fornisce /usr/bin/java).                                                                                                                 
                                                                                                                                                                                               
  Selezione    Percorso                                        Priorità  Stato                                                                                                                 
------------------------------------------------------------                                                                                                                                   
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      modalità automatica                                                                                                   
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      modalità manuale                                                                                                     
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      modalità manuale                                                                                                     
                                                                                                                                                                                               
Press <enter> to keep the current choice[*], or type selection number: 0                                                                                                                       
update-alternatives: viene usato /usr/lib/jvm/java-11-openjdk-amd64/bin/java per fornire /usr/bin/java (java) in modalità automatica                                                           
matteo@TMP258-MG:~$                                                                                                                                                                             
matteo@TMP258-MG:~$                                                                                                                                                                             
matteo@TMP258-MG:~$ iio                                                                                                                                                                         
[1] 9097                                                                                                                                                                                       
matteo@TMP258-MG:~$                                                                                                                                                                             
matteo@TMP258-MG:~$
matteo@TMP258-MG:~$
matteo@TMP258-MG:~$
[1]+  Completato              /home/matteo/.serviio/bin/serviio.sh
matteo@TMP258-MG:~$
matteo@TMP258-MG:~$
Running Serviio - for several years now - on Debian and Win boxes.
R850R biker, sysadmin & DBA, FOSS and Linux enthusiast (desktop_is_home_dir)
<<

bolzass

Serviio lover

Posts: 67

Joined: Thu Jan 02, 2014 6:32 pm

Post Sat Apr 28, 2018 8:08 am

Re: HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS (updat

Hi skiaccianos!,
Nothing to see here....

But to fix what zip is talking about, you should add versions to case... Several ways:
Add lines with versions, or just merge it in the case:
  Code:
# Check if we are using Java9, or 10...
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
case "$JAVA_VERSION" in
    9*|10*) JAVA9_OPTS="--add-modules java.xml.ws,jdk.unsupported" ;;
    *) JAVA9_OPTS="" ;;
esac


Or change the case with only to check if greater or equal than 9:
  Code:
# Check if we are using Java9 or greater...
JAVA_VERSION=$("$JAVA" -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*".*/\1\2/p;')
[ "$JAVA_VERSION" -gt 18 ] && JAVA9_OPTS="--add-modules java.xml.ws,jdk.unsupported" || JAVA9_OPTS=""


I changed it for you by the 2nd options in serviio.sh


[EDITED]. Corrected case words and updated serviio.sh (Thanks zip)
.
Attachments
serviio.sh.zip
(1.1 KiB) Downloaded 336 times
Last edited by bolzass on Sat Apr 28, 2018 2:08 pm, edited 1 time in total.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sat Apr 28, 2018 12:31 pm

Re: HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS

[quote="bolzass"
But to fix what zip is talking about, you should add versions to case... [/quote]
Are you sure your case works?

Java 8's -version results in something like 1.8.0-xxx
Java 9's -version results in something like 9 (not 1.9)

But maybe I'm just not reading the sed line correctly
<<

bolzass

Serviio lover

Posts: 67

Joined: Thu Jan 02, 2014 6:32 pm

Post Sat Apr 28, 2018 1:59 pm

Re: HOWTO: set proper Java in Ubuntu Bionic 18.04 LTS

zip wrote:Are you sure your case works?

Java 8's -version results in something like 1.8.0-xxx
Java 9's -version results in something like 9 (not 1.9)

You are right!, didn't noticed about it :oops:. It should be:
  Code:
# Check if we are using Java9, or 10...
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
case "$JAVA_VERSION" in
    9*|10*) JAVA9_OPTS="--add-modules java.xml.ws,jdk.unsupported" ;;
    *) JAVA9_OPTS="" ;;
esac


zip wrote:But maybe I'm just not reading the sed line correctly

You read it fine, in that case would work also as would result in 9x and 10x (90 & 100 for the last ones) for versions >=9, that are greater than 18 and would take into account new java numbering in the future updates (18.9, etc.) :mrgreen: [this is which I prefer]. Ops :oops: , also mistaken (put 19 not 18..):
  Code:
# Check if we are using Java9 or greater...
JAVA_VERSION=$("$JAVA" -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*".*/\1\2/p;')
[ "$JAVA_VERSION" -gt 18 ] && JAVA9_OPTS="--add-modules java.xml.ws,jdk.unsupported" || JAVA9_OPTS=""



Will correct original post!!!!. Thanks zip!

.

Return to Serviio Support & Help

Who is online

Users browsing this forum: No registered users and 22 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.