I have a problem with my compiled Java application on Ubuntu. It throws UnsupportedClassVersionError
.
I am compiling with a higher JDK version than the one that is
I have added and installed alternatives for Java and Javac with below steps it work for me :
Steps 1: Add the Java and Javac alternatives :
Command to add Javac:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/amazon-jdk-11/bin/java" 1
i.e : "/opt/amazon-jdk-11/bin/javac" this the new path of java
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/amazon-jdk-11/bin/javac" 1
i.e : /opt/amazon-jdk-11/bin/javac is the new path of javac
Steps 2: Installed the Java and Javac alternatives :
sudo update-alternatives --config javac
sudo update-alternatives --config javac
Once you enter above command you will able to see screen like below you can select your number that you want to configure java.
I have selected " 1 "int the list as I wanted to installed "/opt/amazon-jdk-11/bin/java" as my javac.
Verify your Java alternative installation is successful or not with below commands :
which javac
and which java
you will able to see screen like below :