...
If you are migrating to a new major version of Java (e.g. you are moving from Java 8 to Java 11), you will need to remove the previous version from the list of installed programs.
Linux
Install new Java version
Follow instructions to install Java: Install Java
Update JAVA_HOME
...
Minor (patch) upgrades
If you have installed Java as recommended by PhixFlow (Install Java), upgrade Java as recommended for any package installed using the package manager. For example, on Debian based distributions of linux, the generally recommended approach is by using dist-upgrade
.
Major upgrades
If you are upgrading between major versions of Java, you will need to remove the current installation of Java, and install the new version.
Remove the existing Java installation using the standard method for packages installed using the package manager. For example, on Debian based distributions, to remove Java 8 Adoptium OpenJDK, use the commands:
Code Block |
---|
sudo apt-get remove temurin-8-jdk
sudo apt-get purge --auto-remove temurin-8-jdk |
Then install the new version of Java using the instructions given at Install Java, starting from sudo apt-get update
(you do not need to re-install or update the Adoptium repository).
Update service script
The following instructions assume that you have followed the recommended installation instructions for installing Tomcat for PhixFlow: Install Tomcat on Linux. If you have taken a different approach, ensure that you update JAVA_HOME, or which ever setting specifies the installation directory for Java, in your startup process for Tomcat.
Open the tomcat service script at /etc/systemd/system/tomcat.service
Update You may need to update the JAVA_HOME setting in the script to the value of $JAVA_HOME
in your environment. You must make this the full path for the Java installation, you cannot refer to the environment variable in the script. The resulting file will look similar to this:
Code Block |
---|
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/opt/jdk/jdk-11.0.13+8
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat |
If you have moved between major versions of Java (e.g. you are moving from Java 8 to Java 11), update the CATALINA_OPTS as instructed here: Install Tomcat on Linux
Remove old version
The following instructions assume that you have followed the recommended instructions for installing Java for PhixFlow: Install Java. If you have taken a different approach, ensure that any old packages have been removed if you no longer need them (e.g. for a different program that runs on the same server that requires the previous version of Java).
If you have patched Java with a package manager, it will replace the previous version. However, if you are moving between major versions (e.g. from Java 8 to Java 11), you will need to remove the previous version using the package manager.
Delete the previous installation:
Code Block |
---|
cd /opt/jdk
sudo rm -r [PREVIOUS VERSION] |
For example:
...
service script for Tomcat.
To find the new setting, run the command:
Code Block |
---|
update-alternatives --list java |
This will give you the full path of the java program, for example: /usr/lib/jvm/temurin-11-jdk-amd64/bin/java
. The installation directory in this case is /usr/lib/jvm/temurin-11-jdk-amd64
.
Check whether this is different from the current setting of JAVA_HOME in /etc/systemd/system/tomcat.service
. If this is different, update /etc/systemd/system/tomcat.service
to use the new setting for JAVA_HOME, and before you restart the tomcat process, run the command:
Code Block |
---|
sudo systemctl daemon-reload |
Moving from Java 8 to Java 11
If you have moved from Java 8 to Java 11, updateCATALINA_OPTS in /etc/systemd/system/tomcat.service
as instructed here: Install Tomcat on Linux