Sometimes, to compile plugin JARs, run older versions of minecraft, and so on, you require java versions of different kinds. In this article, we'll explain how to install different versions of java and set which java version to use by the system!
☕ Downloading the different Java Versions ☕
For this guide, we will use Eclipse Temurin for Java versions. We will be installing java 8. Go to https://adoptium.net/temurin/releases/ , and choose the following options
Windows as your operating system
Package type as JDK - JRE will not work for compiling plugins or running the game in the java version
Architecture as x64 - most systems are x64, see if you require x32 by checking your system information in control panel
Version as 8 , to install Java 8 - choose a different version if you want to install a different version
Download the .msi file from the site, and open it. Let it install the java software accordingly. Don't tinker with any options unless you know what you're doing. Once done, you'll have installed the specific java version you've chosen!
The files for Java itself will be present in C:\Program Files\Eclipse Adoptium , and based on the different versions, you'll have folders like jdk-18.104.22.168-hotspot for java 17, jdk-8.0.332.9-hotspot for java 8, and so on. Identify the correct java version by the first numbers!
📂 Using a specific java version 📂
To specify a specific java version to use, we'll need to edit the environment variables on your PC. To do this, start by opening Windows Run ( with Win + R or by typing "Run" in the search bar ).
Then, type in sysdm.cpl and click OK. A window will pop up. In that window, go to advanced, and click on "Environment Variables"
Once opened, find the system variables section. In that, find the JAVA_HOME variable. Select it, and click Edit . Next, you'll have to pick the folder in which the java version is installed. Click on "Browse Directory" and navigate to Program Files --> Eclipse Adoptium --> Choose the folder of the java version you want to run, and click OK once chosen.
In our case, the variable value is C:\Program Files\Eclipse Adoptium\jdk-8.0.332.9-hotspot . Keep clicking OK on all the opened windows until the system properties window is closed.
Verify that you're using the correct java version by opening command prompt and typing in java -version . In our case, it says Java 8, as expected!
openjdk version "1.8.0_332" OpenJDK Runtime Environment (Temurin)(build 1.8.0_332-b09) OpenJDK 64-Bit Server VM (Temurin)(build 25.332-b09, mixed mode)
🎮 Choosing the version in your minecraft launcher 🎮
To change the java version utilised in the minecraft game, open the minecraft launcher. Then, head on over to the installations tab at the top. Click on the 3 dots on the install you want to edit, and click Edit.
Scroll down, hit "More options" and then click "browse" in the Java executable field to choose a java version of your choice. In this case, you will need to choose the javaw.exe file, which is normally present in the java folder ( like jdk-8.0.332.9-hotspot ) --> bin --> javaw.exe . Once chosen, click "Open", and then save your installation. You'll have chosen the java version of your choice to run for minecraft
You now know how to choose what Java version while compiling plugins, server softwares, or playing minecraft on different versions!
Updated on: 25 / 07 / 2022