Question or issue on macOS:
So I installed the beta of JDK 8 a while ago to look at some of the examples. I thought for sure by now, it's easy to change between versions.
Doing some Play development with IntelliJ. For some reason, IntelliJ is compiling with 8 even though:
If I go to the Java Preferences page, it does show 8 installed, but there is no option to uninstall it and it doesn't see any of the other versions.
Java version '1.7.009' Java(TM) SE Runtime Environment (build 1.7.009-b05) Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode) Topics: java, jdk, mac osx.
When I do which java, it tells me /usr/bin/java and I do /usr/bin/java -version and it returns 1.6.
Note: with a little fiddling, you can use IntelliJ and JDK7, see here.
How to solve this problem?
- The JDK source code is packaged in a src.jar, and should be in the JDK/Home folder. However, some JDK versions in Mac OSX didn't include the source code or Javadoc. Try find it: sudo find / -name src.jar If you couldn't find the src.jar, then get it from Apple developer website. Download from Apple Developer.
- Installation Guide: SAP GUI 7.40 Java for Mac OSX Notes: -This document was written based on the Mac OSX Mavericks (10.10.2) operating system with Java JDK 8 – Update 40 installed.The filenames of the Java JDK and SAP GUI may differ than those shown in the screenshots.The Java JDK is required. This is different than the JRE.
Solution no. 1:
I was able to unistall jdk 8 in mavericks successfully doing the following steps:
Run this command to just remove the JDK
Run these commands if you want to remove plugins
Solution no. 2:
You just need to use these commands
Solution no. 3:
Managing Java versions on Mac OSX is a nightmare. I recently switched over to using JDK 1.7, deleting JDK 6 from my MacBook entirely (I also had traces of JDK 5 – this laptop has been updated a few times).
Here's what I did to move to JDK 7.
1) download the latest from Oracle (http://www.oracle.com/technetwork/java/javase/downloads/index.html) and install it.
2) Remove (using rm – if you've got backups, you can revert if you make a mistake) all the JDK6 and JRE6 files.
At this stage, you should see:
(and nothing else)
3) In the folder /Library/Java/Extensions/, you'll need to remove all the old jar files, the ones that correspond to other releases of Java. If you don't, you'll get the infamous message about the wrong version of tools.jar (see Builds failing after upgrading to Java7, Missing Tools.jar and bad class versions). It is not enough to rename the jar files, because Java will open every jar in that folder – I moved mine into a sub-directory. It's safe to remove them once you know everything else works.
I haven't found I need to set JAVA_HOME for simple things.
Note: I just tried running IntelliJ and it will not start unless you have Apple's JDK 6 installed (see http://youtrack.jetbrains.com/issue/IDEA-93710). Same is true for Eclipse. Netbeans works fine.
Solution no. 4:
Use /usr/libexec/java_home
; I found these alias and function to be pretty useful in my ~/.profile
:
Solution no. 5:
3) In the folder /Library/Java/Extensions/, you'll need to remove all the old jar files, the ones that correspond to other releases of Java. If you don't, you'll get the infamous message about the wrong version of tools.jar (see Builds failing after upgrading to Java7, Missing Tools.jar and bad class versions). It is not enough to rename the jar files, because Java will open every jar in that folder – I moved mine into a sub-directory. It's safe to remove them once you know everything else works.
I haven't found I need to set JAVA_HOME for simple things.
Note: I just tried running IntelliJ and it will not start unless you have Apple's JDK 6 installed (see http://youtrack.jetbrains.com/issue/IDEA-93710). Same is true for Eclipse. Netbeans works fine.
Solution no. 4:
Use /usr/libexec/java_home
; I found these alias and function to be pretty useful in my ~/.profile
:
Solution no. 5:
I nuked everything Java, JDK, and oracle. I was running Java 8 on OSX El Capitan
Other answers were missing tons of stuff. This answer covers a lot more bases.
Good bye, shovelware.
Solution no. 6:
Java Jdk 7 Download Mac Os X
Here is the official document about uninstalling the JDK.
Solution no. 7:
If you have installed jdk8 on your Mac but now you want to remove it, just run below command 'sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk'
Solution no. 8:
If you uninstall all the files but it still fails, use this line:
Solution no. 9:
To uninstall java of any version on mac just do:
Solution no. 10:
Two ways you can do that:
Removing JDK directly from Users-> Library -> Java -> VirtualMachines -> then delete the jdk folder directly to uninstall the java.
By following the command: (uninstall java 1.8 version )
make sure you are in home directory by using below command, before you write the command:
cd ~/
Hope this helps!
This article shows you how to install Java on Mac OSX, and also how to do Java/JDK version switching.
Tested with
- Mac OS 10.15.3
- JDK 8, 9, 10, 11, 12, 13 (AdoptOpenJDK)
Note
On Mac OSX, Java should installed in this folder; it is Mac's standard.
We will show you two ways to install Java JDK on Mac, via the popular Homebrew package manager and manually installation.
1. Homebrew
1.1 Install Homebrew and update it.
1.2 Add adoptopenjdk/openjdk.
1.3 Find all available JDK.
The output may vary.
1.4 Java 8, 9, 10, 11, 12, 13, choose one to install.
This example will install Java 8 and 11 for testing.
1.5 Where Java is installed? /usr/libexec/java_home -V
Homebrew will install the JDK at folder /Library/Java/JavaVirtualMachines/
, and this folder is Mac's standard folder for Java installs.
1.6 Test it, by default, Mac takes the highest version.
1.7 How to do version switching? Refer to below 3. version switching
2. Manual installation
The example shows you how to download the early access JDK 14 and install it on Mac OSX.
Steps
- Download JDK.
- Puts the JDK folder at
/Library/Java/JavaVirtualMachines
. - Export
JAVA_HOME
.
2.1 Download the early access JDK 14 from the OpenJDK website.
2.2 Extracts tar file to /Library/Java/JavaVirtualMachines
2.3 Export JAVA_HOME
.
Find out where is JDK 14.
Create or edit the existing ~/.bash_profile
with a text editor.
Export JAVA_HOME
, save and exit.
Reflect the changes
2.4 Test it.
3. Version Switching
In this tutorial, we installed the Java 8 and Java 11 via Homebrew
(Step 1), and Java 14 manually (Step 2), so this Mac has three versions now. And the Mac is using the JDK 14.
Note
There are tools like jEnv to manage the Java version switching, but I prefer to manage with export JAVA_HOME
manually, it's simple and easy to understand, no black box magic.
3.1 Create or edit the existing ~/.bash_profile
with a text editor like vim or nano, export JAVA_HOME
to the specified JDK we want to use on Mac.
The above changes will make JAVA_HOME
point to JAVA 8.
3.2 Reflect the changes.
Done.
Java Jdk 7 Download Windows
If we want to switch JDK version again, update the ~/.bash_profile
and export JAVA_HOME
to other JDK version.