Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run an application on a specific Java version?

Tags:

java

linux

ubuntu

How can I run an application with a specific Java version? I have three Java versions intstalled:

myuser@mysystem:~$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      auto mode
* 1            /opt/jdk-9.0.4/bin/java                          1         manual mode
  2            /opt/jdk1.8.0_162/bin/java                       1         manual mode
  3            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

I have Java 9 set as default and I'd like to keep it that way. Still, an application named pdfsam doesn't seem to work properly with Java 9. What command is necessary to run it with openjdk (option 3)?

like image 874
Socrates Avatar asked May 22 '18 09:05

Socrates


Video Answer


1 Answers

You can run java with the absolute path to the installation

This would be your default /usr/bin/java installation

java -version

To change it, use the absolute path

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -version

If you're not running the java command directly, try setting the JAVA_HOME variable:

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/" pdfsam
like image 146
TomVW Avatar answered Sep 19 '22 04:09

TomVW