This topic will help users who are upgrading the Java version on AWS Ubuntu servers. The first 1024 ports on a Linux server are considered privileged, so it is important that you ensure that Java can access common ports.
This topic assumes you have enough familiarity with Linux, Ubuntu, and installation of Java generally to make any adjustments needed to the example commands shown here. All commands are expressed assuming root privileges, but feel free to use the sudo versions if needed.
Check Java Version
Determine supported versions of the JDK using this topic:
Supported Technologies.
See what version of Java the server is running on. Run this (or similar):
Run this (or similar) to install the default JDK:
apt-get install default-jdk
Recheck the Java version again. If it's showing the desired version of Java, then you can skip to
the section about privileged ports below. If this does not update to the desired Java version, move to the next section.
Download and Install a New JDK Version
Run the appropriate commands to download and install the
supported newer version of Java.
The example here is for OpenJDK 12, which is no longer in use, but these commands will give you an idea of the steps needed:
Update Alternatives
Confirm that the new version is present by accessing it via it's full path:
/full/path/to/new/JDK/bin/java -version
Update the alternatives so in the future you can simply type `java -version`. In this example, we show a path for OpenJDK12, which is no longer supported. Adapt these lines to your version:
sh -c 'for bin in /usr/lib/jvm/jdk-12/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'
sh -c 'for bin in /usr/lib/jvm/jdk-12/bin/*; do update-alternatives --set $(basename $bin) $bin; done'
Run this again to confirm the correct version:
Allow Access to Privileged Ports
If your EC2 Ubuntu box is locked down port-wise, you might need to adjust the bind service via the setcap command so Java can access common ports. The command to use will be similar to this:
setcap 'cap_net_bind_service=+ep' 'readlink -f \'which java\''
There are other methods of providing this access, such as including a setting in the
service file that runs LabKey.
Related Topics