0

I have two JEE applications, one runs under Java 8, the other runs under Java 11.

Is there a way to force each application to use the good Java version when I run it (via java -jar xxx.war)? Or do I need to update the Path environment system each time?

My issue is that Java 8 application cannot run with Java 11 because it generates the exception

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

(which is not supported in Java 11).

thomas
  • 1,201
  • 2
  • 15
  • 35

1 Answers1

0

you could do something like this :

export JAVA_LATEST=/usr/local/jdk1.8
export JAVA_OLD=/usr/local/jdk11

in $HOME/.bashrc

JAVA_HOME=$JAVA_OLD 

in shell launcher of your JAVA 8 app

JAVA_HOME=$JAVA_LATEST

in shell launcher of your JAVA 11 app

  • Did you mix up JAVA_LATEST and JAVA_OLD path? And JAVA_HOME [does not really change the java version](https://stackoverflow.com/questions/45246552/java-home-or-path-or-both) when calling `java -jar xxx.war` – samabcde Sep 02 '21 at 14:12