Updating to Adoptium (Eclipse Temurin Open Source Java) - MegaMek/megamek GitHub Wiki

First, We must specify two things: Today's date is 31-May-2024, and our current supported Java version(s) are specified here.

Our current recommended version of Java is:


Eclipse Temurin Java 17 - LTS


This guide is written to assist you in switching to the recommended version when using Adoptium. Adoptium offers a free, open-source alternative to Oracle Java, focusing on community collaboration and vendor neutrality. In contrast, Oracle Java provides enterprise-level support and proprietary features at a cost.

Why use Eclipse Temurin by Adoptium over Oracle, especially for a community open-source project like MegaMek?

Adoptium is ideal for community open-source projects like MegaMek because it:

  • Is free to use, eliminating licensing costs.
  • Is open-source, allowing the community to inspect, modify, and contribute to the code.
  • Ensures vendor neutrality, preventing vendor lock-in and fostering a diverse, collaborative development environment.
  • Offers high-quality, compatible Java runtimes maintained by a global community.

As of the date above we are recommending player use the 0.49.19.1-MILESTONE release with Java 17. But the Table is designed to help players determine the best Java for the version of the program they are using.

Program Version Minimum Java Version Required Java Version Recommended Recommendation
0.49.7-MILESTONE Java 11 Java 11 Upgrade to 0.49.19.1-MILESTONE and Java 17
0.49.11-Development or later Java 11 Java 17 Upgrade to 0.49.19.1-MILESTONE and Java 17
0.49.19.1-MILESTONE Java 11 Java 17 Current Recommended Version. Ensure you're running Java 17
0.48.0-Stable Java 8 Java 17 No longer supported. Upgrade to 0.49.19.1-MILESTONE
0.50.0-Development (Coming Soon) Java 17 Java 17 This Development Cycle hasn't started yet

Please note the Adoptium links default to 64 Bit, Java 17 JRE. If you make changes to the default choices its the players responsibility to understand what they are choosing. Our standard answer will always be to follow the install steps outlined below.


INSTALLATION: The Steps below need to be followed EXACTLY!


Video Tutorial

Before proceeding with the written instructions, you may find it helpful to watch this step-by-step video guide:

How to install Megamek & Java! Play Battletech online! by "The Many Voices"

This video covers the installation process for both MegaMek and Java, providing a visual guide to complement the written instructions below.


Uninstall the old Java versions.

Uninstalling Java on Windows

  1. Open the Programs and Features Settings:

    • On Windows, search for "Add or Remove Programs" in the Start menu search bar and click on the result that appears.
  2. Find Java Installations:

    • In the list of installed programs, look for entries related to Java. These could include:
      • Eclipse Temurin
      • Oracle JDK (Java Development Kit)
      • Oracle JRE (Java Runtime Environment)
      • OpenJDK
      • Amazon Corretto
      • Search for "JRE" or "JDK"
  3. Select the Java Version to Uninstall:

    • Click on the name of the Java version you want to uninstall. If you see multiple entries, select each one you wish to remove.
  4. Click 'Uninstall':

    • After selecting the Java program, click the "Uninstall" button or option.
  5. Follow the On-screen Prompts:

    • Follow the prompts to complete the uninstallation process. You may need to confirm the action and wait for the uninstallation to finish.
  6. Repeat for Other Java Versions:

    • If there are multiple Java versions or distributions installed, repeat steps 3-5 for each one you want to remove.
  7. Check for Leftover Files (Optional):

    • After uninstalling, you can manually check your system for any leftover Java folders or files, often found in locations like C:\Program Files\Java or C:\Program Files (x86)\Java. Delete these folders if you no longer need them.
  8. Reboot after the Uninstall.

Uninstalling Java on macOS

  1. Open Terminal:

    • Press Command + Space, type Terminal, and press Enter.
  2. Remove Java Versions:

    • For JDK: Run sudo rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk
    • For JRE: Run sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    • For Java Web Start: Run sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane

Uninstalling Java on Linux

  1. Open Terminal:

    • Use your preferred method to open the terminal.
  2. Remove Java:

    • For Debian-based systems (e.g., Ubuntu): sudo apt-get remove --purge openjdk*
    • For Red Hat-based systems (e.g., CentOS): sudo yum remove java-*
    • For systems using dnf (e.g., Fedora): sudo dnf remove java-*

By following these steps, you can uninstall Java from your operating system.


  1. Reboot Your Machine: This ensures that all changes take effect properly.

  1. Go to:

The link above is preset to pick the 64 bit JRE (what is needed for play) and Java 17 which we are now recommending as the preferred Java version.

You will need to use the dropdown highlighted in Yellow to choose your Operating System. We recommend leaving the other fields preselected unless you have specific needs.

image

  1. Download for Your OS: Select and download the version appropriate for your operating system.

image

Windows shown as an example. MSI is the installer file, don't grab the zip as the files manually installed and is NOT an installer.


  1. Run the Installer: Download and execute the installer file.

  1. (CRITICAL STEPS) Installation Scope and Custom Setup:

In the newer versions of Adoptium Java they are defaulting the installation scope to "Install just for you...". It's critical you select

"Install for all users of this machine"

image1

If you don't you'll likely get the following error:

image

When you get to the "CUSTOM SETUP" Screen, you need to change the bottom 2 (Set JAVA_HOME variable, and JavaSoft (Oracle) registration keys) to be installed. Click the drop-down and set to "Will be installed on local hard drive".

image

When done, it should look like this (Note the Red X in the first Pics are changed):

image


  1. Complete Installation: Click next to finish the install.

  1. Reboot Again: Reboot your machine to finalize the installation.

If this doesn't work, return to step 1, and redo all steps and double check STEP 6!

You should now have the recommended Java version installed.


TROUBLESHOOTING AND TESTING


For detailed help you'll need to join our Discord. Before you do having these tests run will help us out.

Checking the Java Version via Command Line on Windows, Mac, and Linux


Windows 10 and 11

To check the installed Java version on Windows 10 or 11, you can use the Command Prompt. Follow these steps:

  1. Open Command Prompt:

    • Press Windows + R to open the Run dialog box.
    • Type cmd and press Enter, or click OK.
  2. Check the Java Version:

    • In the Command Prompt window, type the following command and press Enter:
      java -version
    • This command will display the currently installed Java version.
  3. Verify JAVA_HOME:

    • To check if the JAVA_HOME environment variable is set, type the following command and press Enter:
      echo %JAVA_HOME%
    • This command will display the path set for JAVA_HOME. If JAVA_HOME is not set, you will see an empty line or an error message.

Mac

To check the installed Java version on a Mac, you can use the Terminal. Follow these steps:

  1. Open Terminal:

    • Press Command + Space to open Spotlight Search.
    • Type Terminal and press Enter.
  2. Check the Java Version:

    • In the Terminal window, type the following command and press Enter:
      java -version
    • This command will display the currently installed Java version.
  3. Verify JAVA_HOME:

    • To check if the JAVA_HOME environment variable is set, type the following command and press Enter:
      echo $JAVA_HOME
    • This command will display the path set for JAVA_HOME. If JAVA_HOME is not set, you will see an empty line or an error message.

Linux

To check the installed Java version on a Linux system, you can use the Terminal. Follow these steps:

  1. Open Terminal:

    • This can usually be done by pressing Ctrl + Alt + T or by searching for Terminal in your applications menu.
  2. Check the Java Version:

    • In the Terminal window, type the following command and press Enter:
      java -version
    • This command will display the currently installed Java version.
  3. Verify JAVA_HOME:

    • To check if the JAVA_HOME environment variable is set, type the following command and press Enter:
      echo $JAVA_HOME
    • This command will display the path set for JAVA_HOME. If JAVA_HOME is not set, you will see an empty line or an error message.
⚠️ **GitHub.com Fallback** ⚠️