Java Version Issues Ubuntu

Need help? Post your questions here.

Moderator: moderators

Java Version Issues Ubuntu

Postby treed873 » Mon Dec 21, 2020 1:02 pm

I have been running Subsonic for years without issue, but a recent update to openjdk-11-jre has caused it to stop working. I am now getting this error when going to the site: HTTP ERROR: 503. Now, I know that Subsonic requires openjdk-8-jre, and I still have it installed, but a different application requires the newer version of java. I have java 11 as the default. My question is, how do I define the openjdk-8-jre version for subsonic while allowing openjdk-11-jre to be my default?

Thanks
treed873
 
Posts: 7
Joined: Mon Dec 21, 2020 12:48 pm

Re: Java Version Issues Ubuntu

Postby treed873 » Tue Dec 22, 2020 3:15 pm

So an update to my issue, I reverted back to openjdk-8, rebooted, and Subsonic came back. Unfortunately, I run a minecraft server on this same box, and at some point it will no longer run on java 8. Java is self contained, and can have different versions running at the same time, but I'm not sure how to have subsonic "choose" java 8 when running even if it isn't the default java. If anyone has any ideas on this, I would greatly appreciate it.

Thanks for looking
treed873
 
Posts: 7
Joined: Mon Dec 21, 2020 12:48 pm

Re: Java Version Issues Ubuntu

Postby acroyear » Wed Dec 23, 2020 2:03 pm

On my Ubuntu box (20.04)

The service is in /etc/init.d/subsonic
In there, it references /usr/bin/subsonic

In /usr/bin/subsonic is
Code: Select all
# Use JAVA_HOME if set, otherwise assume java is in the path.
JAVA=java
if [ -e "${JAVA_HOME}" ]
    then
    JAVA=${JAVA_HOME}/bin/java
fi


At the top of that file with the SUBSONIC_ env variables, that's where you can set JAVA_HOME to the jdk8 install location.

Then
Code: Select all
sudo service subsonic restart

to bounce it.

No promises, I haven't had to do that yet as I have no need for JDK11 on the same box as a JDK8.
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 721
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA

Re: Java Version Issues Ubuntu

Postby treed873 » Wed Dec 23, 2020 3:54 pm

So this is the Java section of my subsonic.sh file:
Code: Select all
# Use JAVA_HOME if set, otherwise assume java is in the path.
JAVA=java
if [ -e "${JAVA_HOME}" ]
    then
    JAVA=${JAVA_HOME}/bin/java


Do I set my JAVA_HOME like this?
Code: Select all
# Use JAVA_HOME if set, otherwise assume java is in the path.
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
if [ -e "${JAVA_HOME}" ]
    then
    JAVA=${JAVA_HOME}/bin/java
treed873
 
Posts: 7
Joined: Mon Dec 21, 2020 12:48 pm

Re: Java Version Issues Ubuntu

Postby treed873 » Wed Dec 23, 2020 6:10 pm

So that worked, and if anyone is dealing with the same issue, here is what I did:

I edited my subsonic.sh file located in my /usr/share/subsonic/ directory, see below:
Code: Select all
# Use JAVA_HOME if set, otherwise assume java is in the path.
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
if [ -e "${JAVA_HOME}" ]
    then
    JAVA=${JAVA_HOME}/bin/java


The only issue that I need to figure out is, when I rebooted subsonic it did not start automatically. I had to run sudo service subsonic start.

A big thank you to acroyear for pointing me in the right direction! If anyone has an idea about the auto start issue, I'd be much obliged.
treed873
 
Posts: 7
Joined: Mon Dec 21, 2020 12:48 pm

Re: Java Version Issues Ubuntu

Postby cfw34683 » Sun Dec 27, 2020 10:16 pm

This is what i use so that i can have Java 8 and Java 11 installed.
Since i have both installed I used Java 11 by default via
Code: Select all
sudo update-alternatives --config java

This allows me to set the PATH default to java 11

I then modified my service file or what ever way you start it up. I use this command to use Java 8
Code: Select all
/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -Xmx700m -Xloggc:gc_memory_logs.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Dsubsonic.home=/SOME/PATH/TO/subsonic -Dsubsonic.host=0.0.0.0 -Dsubsonic.port=4040 -Dsubsonic.httpsPort=0 -Dsubsonic.contextPath=/music -Dsubsonic.db= -Dsubsonic.defaultMusicFolder=/SOME/PATH/TO/MUSIC -Dsubsonic.defaultPodcastFolder=/SOME/PATH/TO/Podcast -Dsubsonic.defaultPlaylistFolder=/SOME/PATH/TO/playlists -Djava.awt.headless=true -verbose:gc -jar subsonic-booter-jar-with-dependencies.jar"

This starts it up with Java 8 while using Java 11 as default for my Minecraft server.

To enable at start use
Code: Select all
sudo systemctl enable subsonic
cfw34683
 
Posts: 8
Joined: Sat Dec 26, 2020 9:01 pm

Re: Java Version Issues Ubuntu

Postby treed873 » Mon Dec 28, 2020 6:13 pm

I used the
Code: Select all
sudo update-alternatives --config java
to set my default java version to 11. If you don't mind me asking, what version of Ubuntu are you using, and where is your service file?

Thanks
treed873
 
Posts: 7
Joined: Mon Dec 21, 2020 12:48 pm

Re: Java Version Issues Ubuntu

Postby cfw34683 » Tue Dec 29, 2020 1:33 am

treed873 wrote:I used the
Code: Select all
sudo update-alternatives --config java
to set my default java version to 11. If you don't mind me asking, what version of Ubuntu are you using, and where is your service file?

Thanks

I am using Ubuntu 20.10
My subsonic file was located in /etc/systemd/system/ also check /usr/lib/systemd/user
cfw34683
 
Posts: 8
Joined: Sat Dec 26, 2020 9:01 pm

Re: Java Version Issues Ubuntu

Postby treed873 » Tue Dec 29, 2020 2:31 pm

So that is probably the difference. My server is on 16.04, so my subsonic.sh file is located in /usr/share/subsonic/.
treed873
 
Posts: 7
Joined: Mon Dec 21, 2020 12:48 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 23 guests