Changing Java version

Last modified by Aurelie Bertrand on 2024/12/12 15:29

Checking the current version

There are two ways of checking the version currently used by tomcat :

  • Open the page Server status: the Java version in use is indicated in the Global status section (in this example, Java 17).
    Java_server_status_EN.png
     
  • Check the version by going to the Java directory:
    1. In a terminal, enter the following command:
cd /usr/lib/jvm
ll
  1. Look at which version the default-java symbolic link is currently pointing to.
    In the example below, it is pointing to java 11.
    Version java

Changing the Java version

To change the Java version

  1. Shut down tomcat:
sudo service tomcat9 stop
  1. Delete the symbolic link:
sudo rm /usr/lib/jvm/default-java
  1. Recreate the symbolic link to the desired version:
# Change X java-1.1X to the desired version (here java 17)
sudo ln -s /usr/lib/jvm/java-1.17.0-openjdk-amd64 /usr/lib/jvm/default-java
  1. Check that the link points to the desired version:
ll
  1. Start tomcat:
sudo service tomcat9 start