Sdkman is what you want. You can install lots of different flavours and versions of Java and rapidly switch between them with 'sdk default java 8/11/17/whatever'. It updates all the paths and tools from that command Answer from stuie382 on reddit.com
🌐
Minecraft.net
help.minecraft.net › hc › en-us › articles › 360034754852-Change-Game-Version-for-Minecraft-Java-Edition
Change Game Versions for Minecraft: Java Edition
Skip to main content · Back to homepage · Follow Minecraft · English (United States) · Español · Español de Mexico · Português Brasileiro · Indonesian · Consumer Health Privacy
Discussions

How to set or change the default Java (JDK) version on macOS? - Stack Overflow
How can you change the default version of Java on a mac? More on stackoverflow.com
🌐 stackoverflow.com
How do I change Java version in Java? - Ask a Question - TestMu AI Community
Control Panel → System → Advanced → Advanced. PATH can be found under System Variables by clicking on Environment Variables. Modify PATH in the Edit windows by adding the path of your jdk5/bin directory at the top. Please shut the window. Run java -version in a new command prompt window More on community.testmuai.com
🌐 community.testmuai.com
0
June 25, 2022
How do I switch between Java versions?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
13
11
March 20, 2023
How do I change the default version of Java that Curse uses to launch Minecraft?
You can't, it will download it again and again and again, I tricked it out by deleting the content of the folder located in Your documents folder\Curse\Minecraft\Install\runtime\jre-x64\1.8.0_25 delete the entire content of this folder not the folder itself and do not rename it cause it would redownload it again, just replace the content with the content of the folder located here : C:\Program Files\Java\jre1.8.0_91 This will trick the game and it works, but I got back to using MultiMC instead, Curse isn't good performance wise, only good for keeping mods up to date, and even sometimes its not up to date either. More on reddit.com
🌐 r/feedthebeast
9
2
May 23, 2016
Top answer
1 of 16
2562

First run /usr/libexec/java_home -V which will output something like the following:

Matching Java Virtual Machines (3):
1.8.0_05, x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home
1.6.0_65-b14-462, x86_64:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-462, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home

Pick the version you want to be the default (1.6.0_65-b14-462 for arguments sake) then:

export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-462`

or you can specify just the major version, like:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Now when you run java -version you will see:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Add the export JAVA_HOME… line to your shell’s init file.

For Bash (as stated by antonyh):

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

For Fish (as stated by ormurin)

set -x JAVA_HOME (/usr/libexec/java_home -d64 -v1.8)

Updating the .zshrc file should work:

nano ~/.zshrc

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0)

Press CTRL+X to exit the editor Press Y to save your changes

source ~/.zshrc
echo $JAVA_HOME
java -version
2 of 16
608

This answer is an attempt to address: how to control java version system-wide (not just in currently running shell) when several versions of JDK are installed for development purposes on macOS El Capitan or newer (Sierra, High Sierra, Mojave). As far as I can tell, none of the current answers do that (*).

As a developer, I use several JDKs, and I want to switch from one to the other easily. Usually I have the latest stable one for general use, and others for tests. But I don't want the system (e.g. when I start my IDE) to use the latest "early access" version I have for now. I want to control system's default, and that should be latest stable.

The following approach works with Java 7 to 12 at least (early access at the time of this writing), with Oracle JDK or OpenJDK (including builds by AdoptOpenJDK produced after mid-October 2018).

Solution without 3rd party tools:

  • leave all JDKs at their default location, under /Library/Java/JavaVirtualMachines. The system will pick the highest version by default.
  • To exclude a JDK from being picked by default, rename its Contents/Info.plist to Info.plist.disabled. That JDK can still be used when $JAVA_HOME points to it, or explicitly referenced in a script or configuration. It will simply be ignored by system's java command.

System launcher will use the JDK with highest version among those that have an Info.plist file.

When working in a shell with alternate JDK, pick your method among existing answers (jenv, or custom aliases/scripts around /usr/libexec/java_home, etc).


Details of investigation in this gist.


(*) Current answers are either obsolete (no longer valid for macOS El Capitan or Sierra), or only address a single JDK, or do not address the system-wide aspect. Many explain how to change $JAVA_HOME, but this only affects the current shell and what is launched from there. It won't affect an application started from OS launcher (unless you change the right file and logout/login, which is tedious). Same for jenv, it's cool and all, but as far as I can tell it merely changes environment variables, so it has the same limitation.

🌐
HappyCoders.eu
happycoders.eu › java › how-to-switch-multiple-java-versions-windows
How to Change Java Versions in Windows (up to Java 25)
June 11, 2025 - As the default version, I recommend the current release version, Java 24. Accordingly, you should make the following settings: The top list ("User variables") should not contain any Java-related entries. The lower list ("System variables") should contain an entry "JAVA_HOME = C:\Program Files\Java\jdk-24". If this entry does not exist, you can add it with "New…". If it exists but points to another directory, you can change it with "Edit…".
Find elsewhere
🌐
Minecraft Hopper
minecrafthopper.net › help › guides › changing-java-version
Changing Java Version | MinecraftHopper
January 15, 2026 - Follow the instructions here to install the version of Java you need. Open the launcher and click “Installations”. Find the profile you want to change, click the three dots (…) and click “Edit”.
🌐
Oracle
java.com › en › download › help › java_update.html
What is Java Update and how do I change the update schedule?
Java 6 has reached its End of Public Updates, which means there will be no further public secure updates for Java 6. It is recommended that Java 6 be removed from your computer to make it more secure. Change the Java update settings through the Java Control Panel.
🌐
Red Hat
access.redhat.com › solutions › 6232511
How to set default Java version with alternatives tool in RHEL on a per user basis - Red Hat Customer Portal
1 week ago - Selection Command ----------------------------------------------- *+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el8_4.x86_64/jre/bin/java) 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-2.el8_4.x86_64/bin/java) Enter to keep the current selection[+], or type selection number: 2 failed to create /var/lib/alternatives/java.new: Permission denied · Using the alternatives tool allows you to set the system default version as root but does not currently provide options to set different defaults for individual users.
🌐
Oracle
java.com › en › download › help › update_runtime_settings.html
Update Java runtime settings on Windows
Verify that the latest Java Runtime version is enabled by checking the Enabled box. ... Click OK in Java Control Panel window to confirm changes and close the window.
🌐
Medium
medium.com › @rishi.cp01 › java-jdk-versioning-explained-355ba529becf
Java/JDK versioning explained. Just like every language evolves over… | by Kaushik Rishi | Medium
September 21, 2024 - The java -version command gives you the internal version, which is why you see 1.8.0_422. ... Backward compatibility: A lot of tools, scripts, and libraries still check for version numbers using the older 1.x format, so changing it would break ...
🌐
iO Flood
ioflood.com › blog › how-to-update-java
How to Update Java: A Step-by-Step Guide
March 12, 2024 - Let’s get started and master Java updates! You can update Java by visiting the official Java website at: https://www.java.com/en/download/. Download the latest version, and follow the installation prompts.
🌐
Medium
bryantson.medium.com › changing-default-java-version-in-mac-os-x-yosemite-470f11a6084b
Changing Default Java Version in Mac OS X (Yosemite) | by Bryant Jimin Son | Medium
May 11, 2020 - Save the file (for VIM, it is x! in a Command mode) and start a new Terminal window. Type java -version again to see the default Java version changed!
🌐
Medium
medium.com › @ykods › how-to-switch-between-multiple-java-versions-a0f7531fc561
How to Switch Between Multiple Java Versions | Medium
July 11, 2023 - Click the variable and Click Move Up. Move Up until it’s at the Top. Then Click Ok. ... Then Ok once more, finally click Ok again. Annnddd BOOM ! You have successfully changed your Java Version Now.😉
🌐
StickyPiston Hosting
stickypiston.co › account › knowledgebase › 196 › How-to-Change-the-Version-of-Java-that-Minecraft-Uses.html
How to Change the Version of Java that Minecraft Uses
If a modpack uses Java 7 then you will either have to manually change the Java version in the Minecraft Launcher each time you start the pack or install the modpack on a launcher that does allow you to change the Java version.
🌐
Medium
medium.com › @Brilworks › how-to-update-java-jdk-a-simple-guide-0dcc59c7eb5f
How to Update Java JDK [A Simple Guide] | by Brilworks Software | Medium
December 5, 2024 - If you have already installed latest version then you need not to install it, however if you are running an older version, you can update Java JDK by download the latest verison and it will overwrite the older version.
🌐
TestMu AI Community
community.testmuai.com › ask a question
How do I change Java version in Java? - Ask a Question - TestMu AI Community
June 25, 2022 - Control Panel → System → Advanced → Advanced. PATH can be found under System Variables by clicking on Environment Variables. Modify PATH in the Edit windows by adding the path of your jdk5/bin directory at the top.
🌐
Baeldung
baeldung.com › home › java › setting the java version in maven
Setting the Java Version in Maven | Baeldung
January 8, 2024 - Learn how to use the Maven compiler plugin, used to compile the source code of a Maven project. ... We can specify the desired Java version in the compiler plugin.
🌐
List
imagejdocu.list.lu › howto › java › how_to_set_or_change_the_default_java_jdk_version_on_os_x
howto:java:how_to_set_or_change_the_default_java_jdk_version_on_os_x [ImageJ Documentation Wiki]
If you installed several versions of Java on OSX, the first answer in this SO thread describes how to switch between Java versions: http://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-os-x