How to uninstall Java 9 on macOS Sierra - java

I'm having trouble removing Java 9 from my macOS Sierra system.
I accidentally installed Java 9, instead of Java 8, so now all my Eclipse projects give me these warnings: Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
I have used the following guide, but it did not work. Here is my command output when running java -version from the command line:
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

for macOS high sierra removing java 9:
delete the java folder you find in the dir shown to you after executing:
/usr/libexec/java_home -V
use "Go to" in finder and copy and paste the dir to get there

There are two commands which are very simple and useful. If you want to keep multiple versions simply set JAVA_HOME to version you want to use.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_(version you want to use).jdk/Contents/Home
Example--> export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
Else in addition to above command remove/uninstall additional jdk version from your system with below command.
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(version you want to remove).jdk/
Example --> sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/
Please refer below github link for additional details -->
https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392
Thanks

On MacOS you can list what JDKs you have installed and where they are installed to with:
/usr/libexec/java_home -V
If you want to select one of the installed JDKs to be used as default, you can do:
/usr/libexec/java_home -v 1.8
Verify which is now default with java -version.
You can manually add the location of other installed JREs in Eclipse via Preferences / Java / Installed JREs , press Add, and then point it to one of the locations should with the -V option above. You can then check it to select which is default for your projects.

After viewing which Java Virtual Machines I had on my computer using the following command:
ls /Library/Java/JavaVirtualMachines
I realized no additional JDK's would appear after using the Java 8 installer (besides Java 9). When doing further research, it turns out I had installed the other version that is not a SE development kit and it was just working in web browsers, not for the terminal.
For anyone having the same issue, make sure you use the Java SE Development Kit 8.

Uninstall Oracle Java using the Terminal:
Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool.
Remove one directory and one file (a symlink), as follows:
Click on the Finder icon located in your dock
Click on the Utilities folder
Double-click on the Terminal icon
In the Terminal window Copy and Paste the commands below:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
Source:https://www.java.com/en/

I believe the problem is navigating to the correct directory... Once you are where you are supposed to be you can run the sudo commands to remove whichever versions of java you want to remove.
First, run the command in the terminal to determine which version of Java you are running,
java -version
then you can navigate to pesky version of java that you intend to delete by using the following command:
cd /Library/Java/JavaVirtualMachines
then once you see are in the JavaVirtualMachines path, type in ls to see what versions of Java you have installed,
ls
and finally when you know which version or versions of Java you want to uninstall:
sudo rm -rf jdk-10.0.1.jdk #or whichever version you want to delete

I know that you've asked about how to uninstall the java version. But, I think it's important how to manage your Java version in a very good way.
For me, the best way is using SDKMan, a very nice tool for managing you Development tools like Java.
Here you can learn more about it: http://sdkman.io/
You can install your Java version as follow:
$ sdk install java
You can install others tools like Scala:
$ sdk install scala 2.12.1
Uninstall your tools very easy:
$ sdk uninstall java 9
And so on. Hope this helps you in future installation of your development tools.

Related

Choose updated Java SDK in mac from available different version

I'm using mac machine for native-script development and while executing an program it thrown an java error that:
Javac version 1.6.0_65 is not supported. You have to install at least 1.8.0.
so I checked with available install version on developer machine & found two different version detail:
/usr/bin/java -version Showing 1.6.
while system preference -> java control panel -> update. showing V1.8
any suggestion why two version !! Am I missing something here?
Update1: Following help to understand how mac handling this: /usr/bin/java is machine default location, and /Library/Internet.. which is manage explicit.
sudo rm /usr/bin/java
sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
In my case I update default one with downloaded from internet.
Reference link Link1, Link2
You should use /usr/libexec/java_home instead
> /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
you can use it to set JAVA_HOME
export JAVA_HOME=$(/usr/libexec/java_home)
then, you can put this one inside ~/.profile so you have always JAVA_HOME set to most recent release.

How do I install an earlier version of Java SDK on OSX

I have the Java 1.8.0_45 SDK installed on OSX Yosemite (10.10.4), but because of a bug in this release I need to go back to 1.8.0_25
I have downloaded and installed the earlier version (1.8.0_25) but even after a reboot java -versionstill shows 1.8.0_45.
I don't really understand where Java resides on OSX, but how can I get my system back so it uses 1.8.0_25
Try and add this to your ~/.bashrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
You can have multiple JRE/JDK's installed, by changing this path, you can specify which one you use each time you open a new shell.
Here is what I use in my .bashrc
JAVA_VERSION=7
JAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
tmp="JAVA_${JAVA_VERSION}_HOME"
export JAVA_HOME=${!tmp}
export PATH=${!j}/bin:$PATH
Here, you can simply change the 7 to an 8.
This will change the JAVA_HOME, and append the bin directory to your path for general use from the command line.
note you may beed to change your java home's according to the specific release versions installed on your machine.
Ah found it, suprisingly easy:
macbook:JavaVirtualMachines paul$ cd /Library/Java/JavaVirtualMachines
macbook:JavaVirtualMachines paul$ ls
jdk1.7.0_40.jdk jdk1.7.0_45.jdk jdk1.8.0.jdk jdk1.8.0_05.jdk jdk1.8.0_20.jdk jdk1.8.0_25.jdk jdk1.8.0_45.jdk
macbook:JavaVirtualMachines paul$ sudo rm -fr jdk1.8.0_45

Mac OS X and multiple Java versions

How can I install an additional java on MacOS? I installed jdk8 and that works fine. But now I need a jdk7 installation for development purposes. When trying to install the old version via DMG file, i get a warning, that there is already a newer version of java installed and the installer quits.
/usr/libexec/java_home -verbose
Matching Java Virtual Machines (1):
1.8.0_20, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
How to install jdk7 in addition to this one?
The cleanest way to manage multiple java versions on Mac is to use Homebrew.
And within Homebrew, use:
homebrew-cask to install the versions of java
jenv to manage the installed versions of java
As seen on http://hanxue-it.blogspot.ch/2014/05/installing-java-8-managing-multiple.html , these are the steps to follow.
install homebrew
install homebrew jenv
install homebrew-cask
install a specific java version using cask (see "homebrew-cask versions" paragraph below)
add this version for jenv to manage it
check the version is correctly managed by jenv
repeat steps 4 to 6 for each version of java you need
homebrew-cask versions
Add the homebrew/cask-versions tap to homebrew using:
brew tap homebrew/cask-versions
Then you can look at all the versions available:
brew search java
Then you can install the version(s) you like:
brew install --cask java7
brew install --cask java6
And add them to be managed by jenv as usual.
jenv add <javaVersionPathHere>
I think this is the cleanest & simplest way to go about it.
Another important thing to note, as mentioned in Mac OS X 10.6.7 Java Path Current JDK confusing :
For different types of JDKs or installations, you will have different
paths
You can check the paths of the versions installed using /usr/libexec/java_home -V, see How do I check if the Java JDK is installed on Mac?
On Mac OS X Mavericks, I found as following:
Built-in JRE default: /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
JDKs downloaded from Apple: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
JDKs downloaded from Oracle: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
Resources
Removing Java 8 JDK from Mac
http://hanxue-it.blogspot.ch/2014/05/installing-java-8-managing-multiple.html
http://sourabhbajaj.com/mac-setup/index.html
http://brew.sh
https://github.com/Homebrew/homebrew/tree/master/share/doc/homebrew#readme
http://sourabhbajaj.com/mac-setup/Homebrew/README.html
"brew tap” explained https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/brew-tap.md
“brew versions” explained Homebrew install specific version of formula? and also https://github.com/Homebrew/homebrew-versions
https://github.com/caskroom/homebrew-cask
“cask versions”, similar to “brew versions”, see https://github.com/caskroom/homebrew-versions and also https://github.com/caskroom/homebrew-cask/issues/9447
http://www.jenv.be
https://github.com/gcuisinier/jenv
Uninstall jdk8, install jdk7, then reinstall jdk8.
My approach to switching between them (in .profile) :
export JAVA_7_HOME=$(/usr/libexec/java_home -v1.7)
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_9_HOME=$(/usr/libexec/java_home -v9)
alias java7='export JAVA_HOME=$JAVA_7_HOME'
alias java8='export JAVA_HOME=$JAVA_8_HOME'
alias java9='export JAVA_HOME=$JAVA_9_HOME'
#default java8
export JAVA_HOME=$JAVA_8_HOME
Then you can simply type java7 or java8 in a terminal to switch versions.
(edit: updated to add Dylans improvement for Java 9)
For macOS Sierra 420
This guide was cobbled together from various sources (replies above as well as other posts), and works perfect.
0. If you haven't already, install homebrew.
See https://brew.sh/
1. Install jenv
brew install jenv
2. Add jenv to the bash profile
if which jenv > /dev/null; then eval "$(jenv init -)"; fi
3. Add jenv to your path
export PATH="$HOME/.jenv/shims:$PATH"
4. Tap "homebrew/cask-versions"
FYI: "Tap" extends brew's list of available repos it can install, above and beyond brew's default list of available repos.
brew tap homebrew/cask-versions
5. Install the latest version of java
brew install java --cask
6. Install java 6 (or 7 or 8 whatever you need)
brew install java6 --cask
#brew install java7 --cask
#brew install java8 --cask
? Maybe close and restart Terminal so it sees any new ENV vars that got setup.
7. Review Installations
All Java version get installed here: /Library/Java/JavaVirtualMachines lets take a look.
ls -la /Library/Java/JavaVirtualMachines
8. Add each path to jenv one-at-a-time.
We need to add "/Contents/Home" to the version folder.
WARNING: Use the actual paths on your machine... these are just EXAMPLE's
jenv add /Library/Java/JavaVirtualMachines/1.6.0___EXAMPLE___/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk___EXAMPLE___/Contents/Home
9. Check if jenv registered OK
jenv versions
10. Set java version to use (globably)
Where XX matches one of the items in the versions list above.
jenv global XX
Check java version
java -version
Check jenv versions
Should also indicate the current version being used with an asterisk.
jenv versions
DONE
Quick future reference
To change java versions
... See the list of available java versions
jenv versions
... then, where XX matches an item in the list above
jenv global XX
SDKMAN! is a great tool for using multiple versions of Java, Gradle, Groovy, Kotlin, and other JVM tools on Mac OS. Installation and usage doc are easily found on the main site.
(I have no affiliation, just a happy user).
As an example usage, if I type the following in a Terminal window, there is a list of available Java SDK versions (edited for brevity):
$ sdk list java
Available Java Versions
+ 9ea170
> + 8u131
7u141-zulu
Here + denotes that the version is installed. > denotes which version is currently in use. To install a version:
$ sdk install java 7u141-zulu
To use a version in this Terminal window:
$ sdk use java 9ea170
First, you need to make certain you have multiple JAVA versions installed.
Open a new Terminal window and input:
/usr/libexec/java_home -V
Your output should look like:
Matching Java Virtual Machines (2):
11.0.1, x86_64: "Java SE 11.0.1" /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
1.8.0_201, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
Note that there are two JDKs available. If you don’t notice the Java version you need to switch to, download and install the appropriate one from here https://www.oracle.com/java/technologies/downloads/
(JDK 8 is represented as 1.8) .
Once you have installed the appropriate JDK, repeat this step.
Take note of the JDK version you want to switch to. For example, “11.0” and “1.8” are the JDK versions available in the example above.
Switch to the desired version. For example, if you wish to switch to JDK 8, input the following line:
export JAVA_HOME=/usr/libexec/java_home -v 1.8
For 11.0, switch “1.8” with “11.0”
4. Check your JDK version by inputting into Terminal:
java -version
If you have followed all the steps correctly, the JDK version should correlate with the one you specified in the last step.
5. (Optional) To make this the default JDK version, input the following in Terminal:
open ~/.bash_profile
Then, add your Terminal input from step 3 to this file:
SWITCH TO JAVA VERSION 8
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Save and close the file.
As found on this website
So Let’s begin by installing jEnv
Run this in the terminal
brew install https://raw.github.com/gcuisinier/jenv/homebrew/jenv.rb
Add jEnv to the bash profile
if which jenv > /dev/null; then eval "$(jenv init -)"; fi
When you first install jEnv will not have any JDK associated with it.
For example, I just installed JDK 8 but jEnv does not know about it. To check Java versions on jEnv
At the moment it only found Java version(jre) on the system. The * shows the version currently selected. Unlike rvm and rbenv, jEnv cannot install JDK for you. You need to install JDK manually from Oracle website.
Install JDK 6 from Apple website. This will install Java in /System/Library/Java/JavaVirtualMachines/. The reason we are installing Java 6 from Apple website is that SUN did not come up with JDK 6 for MAC, so Apple created/modified its own deployment version.
Similarly install JDK7 and JDK8.
Add JDKs to jEnv.
JDK 6:
JDK 7:
JDK 8:
Check the java versions installed using jenv
So now we have 3 versions of Java on our system. To set a default version use the command
jenv local <jenv version>
Ex – I wanted Jdk 1.6 to start IntelliJ
jenv local oracle64-1.6.0.65
check the java version
java -version
That’s it. We now have multiple versions of java and we can switch between them easily. jEnv also has some other features, such as wrappers for Gradle, Ant, Maven, etc, and the ability to set JVM options globally or locally. Check out the documentation for more information.
In the same spirit than #Vegard (lightweight):
Install the wanted JDKs with Homebrew
Put this jdk bash function and a default in your .profile
jdk() {
version=$1
export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
java -version
}
export JAVA_HOME=$(/usr/libexec/java_home -v11); # Your default version
and then, to switch your jdk, you can do
jdk 9
jdk 11
jdk 13
Based on https://github.com/AdoptOpenJDK/homebrew-openjdk.
Manage multiple java version in MAC using jenv
Install homebrew using following command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
install jenv and activate jenv
brew install jenv
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
tap cask-versions
brew tap homebrew/cask-versions
search available java version that can be installed
brew search java
E.g. to install java6 use following command
brew install cask java6
Add multiple versions of java in jenv
jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Note:- if you get error like ln: /Users/<username>/.jenv/versions/oracle64-1.8.0.231: No such file or directory, then run following:-
mkdir -p /Users/<username>/.jenv/versions/oracle64-1.8.0.231
Rehash jenv after adding jdk’s
jenv rehash
List known versions of java to jenv
jenv versions
Set default version
jenv global oracle64-1.8.0.231
Change java version for a project
jenv local oracle64-1.6.0.65
set JAVA_HOME with the same version as jenv
jenv exec bash
echo $JAVA_HOME
I find this Java version manager called Jabba recently and the usage is very similar to version managers of other languages like rvm(ruby), nvm(node), pyenv(python), etc. Also it's cross platform so definitely it can be used on Mac.
After installation, it will create a dir in ~/.jabba to put all the Java versions you install. It "Supports installation of Oracle JDK (default) / Server JRE, Zulu OpenJDK (since 0.3.0), IBM SDK, Java Technology Edition (since 0.6.0) and from custom URLs.".
Basic usage is listed on their Github. A quick summary to start:
curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh
# install Oracle JDK
jabba install 1.8 # "jabba use 1.8" will be called automatically
jabba install 1.7 # "jabba use 1.7" will be called automatically
# list all installed JDK's
jabba ls
# switch to a different version of JDK
jabba use 1.8
I am using Mac OS X 10.9.5. This is how I manage multiple JDK/JRE on my machine when I need one version to run application A and use another version for application B.
I created the following script after getting some help online.
#!bin/sh
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/Library/Java/JavaVirtualMachines/'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=/Library/Java/JavaVirtualMachines/$1/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
fi
}
function removeFromPath() {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
}
#setjdk jdk1.8.0_60.jdk
setjdk jdk1.7.0_15.jdk
I put the above script in .profile file. Just open terminal, type vi .profile, append the script with the above snippet and save it. Once your out type source .profile, this will run your profile script without you having to restart the terminal. Now type java -version it should show 1.7 as your current version. If you intend to change it to 1.8 then comment the line setjdk jdk1.7.0_15.jdk and uncomment the line setjdk jdk1.8.0_60.jdk. Save the script and run it again with source command. I use this mechanism to manage multiple versions of JDK/JRE when I have to compile 2 different Maven projects which need different java versions.
Jenv on Mac Sierra:
if not working after install, do this bug fix to add java executable to path
export PATH="$HOME/.jenv/shims:$PATH"
even though eval "$(jenv init -)" could do this job. The reason is /bin folder is not there anymore as describe in it's homepage, but shim folder is used as /bin instead.
Make sure ~/.jenv is there
which java may print /Library/...
jenv global 1.8
jenv shell 1.8
Eventually, which java gives you:
/Users/xxxx/.jenv/shims/java
I answer lately and I really recommand you to use SDKMAN instead of Homebrew.
With SDKMAN you can install easily different version of JAVA in your mac and switch from on version to another.
You can also use SDKMAN for ANT, GRADLE, KOTLIN, MAVEN, SCALA, etc...
To install a version in your mac you can run the command sdk install java 15.0.0.j9-adpt
I know that this question already have a lot of answers, but I want to share my solution only using Temurin and bash.
AdoptOpenJdk is deprecated and that is why I'm using Temurin.
1. Download Temurin using the mirrors or a package manager
$ brew install --cask temurin
And for other versions (like Java 8):
$ brew tap homebrew/cask-versions
$ brew install --cask temurin8
2. Add a bash script into your bash profile
Open your ~/.zshrc or ~/.bash_profile (depending on what you're using it)
And add this code:
set-jdk() {
jdkversion=$1
export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-"$jdkversion".jdk/Contents/Home;
export PATH=$PATH:$JAVA_HOME/bin;
java -version
}
3. Restart your terminal and change your Java version
$ set-jdk N N being the Java version that you want and it's already installed
e.g.
$ set-jdk 8 To change to Java 8 / 1.8
Few considerations:
It will only keep the Java version on the terminal session that you used the set-jdk command
It won't set the Java version as global
When you want to add the JAVA_HOME into another script/application, you can set /Library/Java/JavaVirtualMachines/temurin-<version>.jdk/Contents/Home (change the for the desired Java version. Like this JD-GUI example)
Enjoy
As of 2023, brew install --cask zulu8 didn't work for me on Apple chip. brew install openjdk#8 also didn't not. The only one solution worked for me was brew install --cask adoptopenjdk8 and then of course vim ~/.zshrc and inside:
export JAVAC_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
export JAVA_11_HOME=$(/usr/libexec/java_home -v11)
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
alias javac8='export JAVA_HOME=$JAVAC_HOME'
alias java11='export JAVA_HOME=$JAVA_11_HOME'
alias java8='export JAVA_HOME=$JAVA_8_HOME'
switch from terminal using javac8 to a freshly installed (different) version. Note: you can have different Java versions than me, so it's just an example.
Edit: for some reason it takes some time once it's activate. It seems to me a restart of a laptop is needed.
Here's a more DRY version for bash (Based on Vegard's answer)
Replace 1.7 and 1.8 with whatever versions you are interested with
and you'll get an alias called 'javaX'; where 'X' is the java version (7 / 8 in the snippet below) that will allow you to easily switch versions
for version in 1.7 1.8; do
v="${version: -1}"
h=JAVA_"$v"_HOME
export "$h"=$(/usr/libexec/java_home -v $version)
alias "java$v"="export JAVA_HOME=\$$h"
done
To install more recent versions of OpenJDK, I use this. Example for OpenJDK 14:
brew info adoptopenjdk
brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk14
See https://github.com/AdoptOpenJDK/homebrew-openjdk for current info.
I followed steps in below link - https://medium.com/#euedofia/fix-default-java-version-on-maven-on-mac-os-x-156cf5930078 and it worked for me.
cd /usr/local/Cellar/maven/3.5.4/bin/
nano mvn
--Update JAVA_HOME -> "${JAVA_HOME:-$(/usr/libexec/java_home)}"
mvn -version
New commands for installing Java via Homebrew:
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
brew cask install adoptopenjdk/openjdk/adoptopenjdk11
See the homebrew-openjdk repo for the latest commands.
Installing Java
You can install Java via Homebrew, Jabba, SDKMAN or manually. See this answer for details on all the commands.
Switching Java versions*
You can switch Java versions with jenv Jabba, SDKMAN or manually. See details on all the switching commands here.
Best solutions
Jabba is designed to work on multiple platforms, so it's a good option if you want a solution that'll also work on Windows
Using Homebrew to download Java versions and jenv to switch versions provides a nice workflow. jenv makes it easy to work with Java versions stored in any directory on your machine, so it's a good alternative if you're interested in storing Java in non-default directories.
Using SDKMAN to download Javas and switch versions is another great alternative
Manually switching should be avoided because it's an unnecessary headache.
Function to manually switch Java versions
Here's the Bash / ZSH function for manually switching Java versions (by OpenJDK):
jdk() {
version=$1
export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
java -version
}
There are great tools for switching Java versions, so I highly recommend against doing it manually.
Here is a great tutorial
https://medium.com/#chamikakasun/how-to-manage-multiple-java-version-in-macos-e5421345f6d0
by using jEnv installed by brew
or you can check out homebrew-openjdk
https://github.com/AdoptOpenJDK/homebrew-openjdk managing version using brew Tap
To find the available Java versions:
brew search java
To install the latest stable version (19 as of today):
brew info java
brew install java
For the system Java wrappers (eg: IDEs) to find the latest JDK, symlink it with:
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
To install a specific version (11):
brew install java11
For the system, Java wrappers to find JDK 11:
sudo ln -sfn /opt/homebrew/opt/openjdk#11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
You can have one of the OpenJDK versions in your PATH. Add one of the following lines to your ~/.bash_profile
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH
export PATH="/opt/homebrew/opt/openjdk#11/bin:$PATH
Then,
source ~/.bash_profile
I solved this error on my mac m1 air just by adding the path of new jdk version in ~/.zshrc file.
I have multiple jdks in my /Library/Java/JavaVirtualMachines path. So I can choose any version I wish to set as my default java path.

Eclipse can't find Java, Java not installed

I was following an online tutorial on how to delete JVM 6 and install JVM 7 to be able to run eclipse on my Mac running OS X 10.9.2. First I installed the latest JDK.
I was instructed to type the following commands to delete JVM 6.
sudo rm -rf /System/Library/Java/JavaVirtualMachines/
sudo rm /private/var/db/receipts/com.apple.pkg.JavaForMacOSX*
sudo emacs /Library/Receipts/InstallHistory.plist
Then, I set the symlinks for java 7, with these commands.
sudo rm /usr/bin/java
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java /usr/bin/java
This should be it. Now my computer does not have any version of Java on it:
the command "java -version" responds with "java: command not found"
I also cannot direct to the folder with cd Library/Java responding with "Folder does not exist", however I can browse to that folder manually.
Can someone please assist me in getting Java 7 running on my computer so I can use eclipse.
Any help much appreciated and keep in mind I'm a Mac newb.
this is the tutorial i followed:
http://www.cc.gatech.edu/~simpkins/teaching/gatech/cs2340/guides/java7-macosx.html
Did you change the PATH variable to point to the newer version?
/usr/libexec/java_home is the starting point for switching java versions on the command line. Check out this post to understand how to handle different java versions on the Mac.
I think that the folder still exists but executables didn't existe because anh version of Java is installed.
Normally you have just to download the jdk or jre on oracle web site and run the package downloaded

JRE error when trying to install Matlab Compiler Runtime

Once again, I spent much time trying to get something to work without success.
I want to install MATLAB Compiler Runtime on my Ubuntu 13.04, where there is no MATLAB installed.
Here's what I did:
I downloaded the 64-bit Linux version R2012b(8.0) off of
http://www.mathworks.com/products/compiler/mcr/index.html?s_cid=BB.
Then, I switched into the folder and tried to install via
sudo ./install just to receive the following message:
Error: Cannot locate Java Runtime Environment (JRE).
The directory /home/konni/Downloads/MCR_R2012b_glnxa64_installer/sys/java/jre/glnx86/jre does not exist.
And, it does not exist indeed, but there exists a folder with "glnxa86" instead of "glnx86". I wouldn't just want to rename it, though.
I do have a JRE installed on my machine, btw:
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)
I have absolutely no clue what to do. The problems I found using google didn't quite help me, either...
Maybe you have an idea?
I'd greatly appreciate any help! :-)
If the only problem is finding the JRE, then the command line switch -javadir will get you done:
./install -javadir /usr/lib/jvm/java-7-openjdk-i386/jre/
I had the same problem recently when installing a software that required a 7.13 MCR on an Ubuntu 17.10.
In this
https://www.linuxquestions.org/questions/linux-newbie-8/matlab-7-5-compiled-runtime-for-64-bit-linux-installation-no-jre-error-838281/
I found that the 32 bit version installs fine, and it did, but obviously, that didn't solve my problem.
However, I found a way to do it. The trick is that the installer needs the old JRE (1.5) and will not work with JDK 8.
So the first step is to run
./MCRInstaller.bin -is:extract
this will create a directory called istemp... something, for me istemp23732345211606.
ls
jre1.5.0-linux-amd64.bin JVMNotFound.txt setup.jar Verify.jar
It is tempting to run the setup.jar directly, do try, but with Java 8, I only got the following error message:
Could not load wizard specified in /wizard.inf (104)
But perhaps it will work for you. People who get the above mentioned error with wizard.inf should look further, because the installer needs JDK 5 to run.
I chose not to use the bundled version but downloaded the JDK 5 from Oracle. The bundled version might work as well - I did not try.
You can download JDK 5 from here:
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html#jdk-1.5.0_22-oth-JPR
Extract the downloaded archive (chmod +x the bin and run), then copy the files to /usr/lib/jvm/java5
Rename the jdk1.5.0_022 or anything to jdk1.5.0 to make it simple.
Fix attributes:
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/java5/jdk1.5.0
Then run:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java5/jdk1.5.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java5/jdk1.5.0/bin/javac" 1
Now chose the jdk 5 as default
sudo update-alternatives --config java
And selecting the appropriate option.
Check that it worked
java -version
You should see something like this:
java version "1.5.0_22" Java(TM) 2 Runtime Environment, Standard
Edition (build 1.5.0_22-b03) Java HotSpot(TM) 64-Bit Server VM (build
1.5.0_22-b03, mixed mode)
Now you can run the setup.jar file in the extracted directory (istemp...)
sudo java -jar setup.jar
I recommend that you chose a contemporary java by running
sudo update-alternatives --config java
again.
When running the installer.sh, use the command line option "-is:javahome [path to your java jre folder]".
For instance, I installed below a java 8 jre on an old matlab compiler 2007b as follow:
sudo /opt/installer.sh -console -is:javahome /usr/lib/jvm/java-8-openjdk-amd64/jre/
I had same problem. The problem is you are installing 64-bit matlab on 32-bit ubuntu. use 32-bit matlab and install in ubuntu 32-bit. use 64-bit matlab and install in ubuntu 64-bit. Please like the answer if it was helpful.

Categories

Resources