Related
Could someone please let me know the steps to install Java on a Mac.
I did brew install java
I get this
Warning: openjdk 17.0.1 is already installed and up-to-date.
To reinstall 17.0.1, run:
brew reinstall openjdk
If I do java -version, I get this.
openjdk version "13.0.8" 2021-07-20
If I have navigate to /Library/Java, I have 2 empty directories.
Where is java 17 installed??
In 2023, even if you can use just brew..
brew install openjdk#17
Java will be installed here:
/usr/local/opt/openjdk#17/bin/java
For the system Java wrappers to find this JDK, symlink it with:
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
...give a try to sdkman, it's far better than brew
curl -s "https://get.sdkman.io" | bash
then open a new shell and try list to see what you could install ;-)
sdk list java
At time of writing you could use:
sdk install java 17.0.4.1-tem
Java will be installed here:
/Users/freedev/.sdkman/candidates/java/17.0.4.1-tem
Java doesn't mind if you install multiple versions. This is often required; java is not backwards compatible (it tries to change little, but e.g. the java8 to java9 transition broke a ton of stuff, much of it needless and much of it not reasonably expectable or fixable by libraries and apps, so a bunch of java apps and libraries only run on java8 - just an example).
So, yes, you have installed JDK17. Also, yes, if you just run java without specifying which one you want, you so happen to get java13 here.
To see all installed javas, you can run:
/usr/libexec/java_home -V
to 'override', you can use something like (depends on which shell you're using on your mac):
export JAVA_HOME=`/usr/libexec/java_home -v 17`
(the backticks mean: Run this then take the output of it and treat that as the 'value' of the expression. here, assign it to the JAVA_HOME env var. -v 17 requests a path to java 17. The -V option lists all and is meant for your eyeballs, not for scripts. The -v option is mostly for scripting, and that's how we're using it here).
JAVA_HOME decides which java is used by some things, but the java you get when you just type java is /usr/bin/java, and that executable is actually just a wrapper that picks a java to run from amongst all installed versions. It uses JAVA_HOME to decide which java to actually run. There are wrappers for all the common commands (javac, too). You can always run e.g. which javac to see what that actually runs; you probably see /usr/bin/javac. Everything in /usr/bin is one of these wrapper thingies that looks at JAVA_HOME and then runs the binary it finds there.
To specify version 17
brew install openjdk#17
Later I add create a link:
sudo ln -sfn /usr/local/opt/openjdk#17/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk-17.jdk
And use jenv to control which java version to use
To used the version installed by homebrew rather than the one installed by the OS you can get detailed information from homebrew by typing
brew info java
Currently it states
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.
If you need to have openjdk first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk you may need to set:
export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"
For Homebrew, the package that installs the new AdoptOpenJDK is named as temurin. So you need to use below command:
brew install --cask temurin17
If you get any error like temurin cask not available then update brew using below commands:
brew update
brew tap homebrew/cask-versions
To switch quickly between different versions of java add the entries in bashrc as per your jdk versions like:
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"
alias j17="export JAVA_HOME=`/usr/libexec/java_home -v 17`; java -version"
Steps to install
You asked:
let me know the steps to install Java on a Mac.
Download an installer free-of-cost from vendors such as Adoptium, Azul Systems, Bellsoft, Amazon, Oracle, Microsoft, SAP, and others.
Run installer app.
Quit the installer app when done.
Verify installation by typing on a command-line in Terminal.app:java --version
Delete installer app that you downloaded.
Configure your IDE to use that new Java implementation you installed.
Java location
You asked:
Where is java 17 installed??
/Library/Java/JavaVirtualMachines/
In the Finder, choose Go > Go to Folder, and paste /Library/Java/JavaVirtualMachines/.
Note that this is not the Library folder within your home folder. We are not referring to /Users/your_user_name/Library/…. We are referring to the root Library folder that applies across all the user accounts on this Mac.
You said:
I did brew install java
No need for the Homebrew package manager. If you already enjoy using the brew tool, proceed. But if new to Homebrew, skip it if your only goal is to install Java. Just use an installer for Java as you would for many Mac apps.
JavaFX
You added a tag for javafx.
Be aware that for JavaFX, you have two options:
Include the necessary OpenJFX libraries within your development project and within your final app, or …
Use a JDK that includes the JavaFX/OpenJFX libraries.
At least two vendors provide JDK installers that include the JavaFX/OpenJFX libraries:
Azul Systems (ZuluFX)
Bellsoft (LibericaFX)
This answer is specifically if you use Intellij on a Mac
Within IntelliJ, you can use the IDE to add new JDKs of selected versions from common vendors. Instructions for this are here:
Setup the project JDK
When setting up the JDK, you can either:
Select a pre-existing JDK which has been registered with the IDE OR
Use the Add JDK option to add a new JDK which you previously downloaded and installed using the method outlined in Basil's answer OR
Use the Download JDK option to choose a vendor and version of the JDK that the IDE will automatically download, install and make available for selection.
The JDKs installed by Idea will be located in the same location as outlined in Basil's answer for a manual install /Library/Java/JavaVirtualMachines/.
One common issue is that the version of the JDK registered for the project differs from the default version used in the terminal. This can sometimes mean that the app works when run in Idea, then fails when run in the terminal (or, at least that it is executed against a version of the JDK you didn't expect).
To select the version of the JDK to run in the terminal, configure the Java home setting as outlined in rzwitserloot's answer.
export JAVA_HOME=`/usr/libexec/java_home -v 17`
Also, some tools such as the openjfx maven plugin will not use the java version selected in Idea when executing a call to a JDK tool like jlink, but will instead have their own mechanism for finding a JDK to use (e.g. look at JAVA_HOME or use the Maven toolchains plugin). So it is always good to check the JAVA_HOME variable and ensure that it is set to a reasonable value, both for terminal execution and for effective use of Java development tools that may rely on it.
I think that answers here are not fully out of topic, but from my point of view, my case is exactly the same as that of the author. I had already installed java 8, 11, and 13. All of them resides at:
/Library/Java/JavaVirtualMachines/
Nevertheless when I tried to find the path of JDK 17 it resides:
/usr/local/Cellar/openjdk
I use Mac OS Big Sur and the JDK was installed with homebrew
Brew now supports searching old formulae and allowing you to install a specific version. I'm using Homebrew 3.5.2-117-gb941470
Create a local tap: brew tap-new --no-git local/openjdk
Ask Brew to find the formulae of the version you want: brew extract --version 17.0.2 openjdk local/openjdk
Install Java 17 using your new local tap: brew install openjdk#17.0.2
Link the JDK into the MacOS JVM Dir: sudo ln -sfn /usr/local/opt/openjdk#17.0.2/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk17.0.2.jdk
Check Java 17 is available: /usr/libexec/java_home -V
Set Java Home: export JAVA_HOME=$(/usr/libexec/java_home -v17)
Check current version of Java is correct...
$ java --version
openjdk 17.0.2 2022-01-18
The following method installs Java without the need for any additional tools or package managers.
Go to https://jdk.java.net/17/ and download the latest macOS archive.
Download the latest Adoptium release for the Java 17 branch by going to https://adoptium.net/temurin/releases/ and be sure to select the tar.gz version.
The archive is either for x64 (Intel CPU) or for AArch64 (Apple Silicon / M1 CPU).
Then, open a Terminal, and extract the downloaded archive to the system path for Java virtual machines:
cd Downloads
tar xzf OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.5_8.tar.gz -C /Library/Java/JavaVirtualMachines
Even though JRE 8 is installed on my MAC OS Yosemite 10.10.3,while running the Android present in tools in sdk - the error - " No Java Runtime present,requesting to install " gets displayed in terminal- how do i solve this issue?
I wanted to install Xamarin test recorder - after installing they
asked me to install Android sdk
SDK is downloaded in Library/Developer/Xamarin/android-sdk
Now when I run Android present in tools folder - I get the error -
No Java run time
I've installed JRE 8 with get the verified
java version from their site
Can someone please help!!
You have to install the full JDK, not only the JRE.
I had the same issue and solved by installing JDK.
Please use this link to download the latest JDK version 19.
After installing openjdk with brew and runnning brew info openjdk I got this
And from that I got this command here, and after running it I got Java working
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
2021 solution
TL;DR
brew install temurin
Details
On an M1 Mac/Apple Silicon (running Big Sur), I had already openjdk installed. As signaled in a previous answer by Mohammed, openjdk is keg-only with brew, and hence requires adding a symlink.
After following this, it solved the No Java Runtime present error, but rJava was complaining about missing libjvm.dylib and that existing libraries were for the wrong architecture:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(jvm, FALSE)
error: unable to load shared object '/opt/homebrew/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib':
dlopen(/opt/homebrew/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib, 10):
no suitable image found. Did find:
/opt/homebrew/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib:
mach-o, but wrong architecture
Installing Eclipse Temurin (previously AdoptOpenJDK) (and removing the previously created symlink in /Library/Java/JavaVirtualMachines/openjdk.jdk) immediately solved both issues seamlessly.
Just run brew install temurin and everything should be OK.
I didn't need the full JDK, I just needed to make JRE work and none of the other answers provided above worked for me.
Maybe it used to work, but now (1st Jul 2018) it isn't working. I just kept getting the error and the pop-up.
I eventually solved this issue by placing the following JAVA_HOME export in ~/.bash_profile:
export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Hope this helps someone.
I'm running Mac OS High Sierra.
I just had to do the following on Mac:
brew install openjdk
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
export JAVA_HOME="/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home"
java --version
If you came across the error when tried to generate a jks file (keystore), so try adding
/Applications/Android\ Studio.app/Contents/jre/Contents/Home/bin/keytool
before running the command, like so:
/Applications/Android\ Studio.app/Contents/jre/Contents/Home/bin/keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Since it sounds like your JAVA_HOME variable is not set correctly, follow the instructions for setting that.
Setting JAVA_HOME environment variable on MAC OSX 10.9
I would imagine once you set this, it will stop complaining.
Maybe someone is still having the same issue. You can install openjdk using homebrew, and then add the new JDK bin directory to the front of your path:
cd ~
brew install openjdk
echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> .bash_profile
source .bash_profile
Pre-Requisite:
I already had java11 installed on my machine using brew.
Step-1: brew info java11
output:
/opt/homebrew/Cellar/openjdk#11
USER1-MacBook-Pro JavaVirtualMachines % brew info java11
openjdk#11: stable 11.0.12 (bottled) [keg-only]
Development kit for the Java programming language
https://openjdk.java.net/
/opt/homebrew/Cellar/openjdk#11/11.0.12 (670 files, 273.0MB)
Poured from bottle on 2021-10-09 at 13:07:04
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openjdk#11.rb
License: GPL-2.0-only
==> Dependencies
Build: autoconf ✔
==> Requirements
Build: Xcode ✘
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk#11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
openjdk#11 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have openjdk#11 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/openjdk#11/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk#11 you may need to set:
export CPPFLAGS="-I/opt/homebrew/opt/openjdk#11/include"
==> Analytics
install: 44,188 (30 days), 149,578 (90 days), 433,845 (365 days)
install-on-request: 19,074 (30 days), 63,262 (90 days), 187,286 (365 days)
build-error: 0 (30 days)
Step-2: Append openJDK path to existing path.
echo 'export PATH="/opt/homebrew/opt/openjdk#11/bin:$PATH"' >> ~/.zshrc
Step-3: Source existing shell or open new terminal to validate changes
source ~/.zshrc
Step-4: Check path is added
which java
output: /opt/homebrew/opt/openjdk#11/bin/java
Step-5:
java --version
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)
working by following command
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"
TL;DR
For JDK 11 try this:
To handle this problem in a clean way, I suggest to use brew and jenv.
For Java 11 follow this 2 steps, first :
JAVA_VERSION=11
brew reinstall jenv
brew reinstall openjdk#${JAVA_VERSION}
jenv add /usr/local/opt/openjdk#${JAVA_VERSION}/
jenv global ${JAVA_VERSION}
And add this at end of your shell config scripts ~/.bashrc or ~/.zshrc
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"
Problem solved!
Then restart your shell and try to execute java -version
Note: If you have this problem, your current JDK version is not existent or misconfigured (or may be you have only JRE).
In 2022:
No need to download Java anymore, once Android Studio is installed.
Even though Java 11 is embedded with Android Studio now, on Mac sometimes this problem arises and the Java runtime is not found.
So, I have solved this problem by doing these two steps:
In Android Studio go to File > Project Structure. If, under the SDK entry, you can see there is no default SDK selected, but a text in red "No SDK", click on it and you will find an SDK / JDK list, select one of them. Thats it.
Make sure you run Android Studio from Application Folder.
For this copy the Android Studio launcher to the Application folder. Then in the Finder, go to the Application folder. Right-click on it. Click on "Show package contents", then navigate up to jre folder. Copy the folder and paste it into your home folder.
Now setup the path from the terminal: you can create a folder named java_jre, and the path must be set to jre/contents/Home :
Noors-Mac-mini:bin noorhossain$ export JAVA_HOME="/Users/noorhossain/java_jre/jre/Contents/Home"
// now checking the version :
Noors-Mac-mini:bin noorhossain$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
OpenJDK 64-Bit Server VM (build 11.0.11+0-b60-7772763, mixed mode)
I solved the problem by installing oracle-sdk with brew.
brew install oracle-jdk --cask
In 2022, only if Android studio is installed:
Check if JDK is installed in Android studio. In Android Studio go to File > Project Structure. Under the SDK entry, if there is no default JDK selected, select from the list, or if there isn't any, add JDK and then apply to install.
After the JDK is installed in Android studio, you just need to add the JDK path directly from your Android Studio. Run the below command in the terminal and that's it.
echo 'export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"' >> ~/.zshrc
Now, check if it's working.
❯ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
OpenJDK 64-Bit Server VM (build 11.0.11+0-b60-7772763, mixed mode)
No need to install any package from brew or create any symlink. The Java is already embedded with the Android studio and we can use this directly for our system.
In newer versions of OS X (especially Yosemite, EL Capitan), Apple has removed Java support for security reasons.
To fix this you have to do the following.
Download Java for OS X 2015-001 from this link: https://support.apple.com/kb/dl1572?locale=en_US
Mount the disk image file and install Java 6 runtime for OS X.
After this you should not be seeing any of the below messages:
- Unable to find any JVMs matching version "(null)"
- No Java runtime present, try --request to install.
This should resolve the issue for the pop-up shown below:
Below is worked for me on macos mojave 10.14.6 version
I installed current jdk(https://www.oracle.com/java/technologies/javase-downloads.html)
Then do respectively;
vim .bash_profile
add "export JAVA_HOME=$(/usr/libexec/java_home)" to bash_profile
source .bash_profile
it is done. And you can check the version with java -version command.
If you are having this issue for the same reason that I am, I can tell you why it is happening. I just don't know how to fix it yet.
Here it is:
I am using JDK version 1.8 on MacOS Big Sur. I do not want to have to install a later version of the JDK because all my projects run on 1.8. But here's the thing.... On the command line
java -version
Returns this:
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-bre_2021_08_14_21_34-b00)
OpenJDK 64-Bit Server VM (build 25.302-b00, mixed mode)
but a slightly different command (version prefixed with 2 dashes instead of 1)
java --version
returns this error:
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This is because Java 8 uses single dash version, all JDKs after use double dash.
So the machine, when looking for JAVA_HOME, is also using double dashes and getting the error.
just run this
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
I have Mojave 10.14.6 and the only thing that did work for me was:
setting JAVA_HOME to the following:
export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
source .bash_profile (or wherever you keep your vars, in my case .zshrc)
Hope it helps! You can now type java --version and it should work
It's worth noting that with my current version of SQLDeveloper (21.2.1), there's another way to specify the JDK location. In my case, I was able to open up ~/.sqldeveloper/21.2.1/product.conf and set the JavaHome directive to the appropriate directory. I use jabba for JDK version management, and this path was something like ~/.jabba/jdk/amazon-corretto#1.8.292-10.1/Contents/Home. Needless to say, just setting that config value and restarting SQLDeveloper left me with a running copy again. This should work with any version of SQLDeveloper given the product.conf file exists inside your user's .sqldeveloper directory appropriate for the version you are using.
install JDK it will work ,
here is the jdk link to download .
link: https://www.oracle.com/technetwork/java/javase/downloads/jdk13-downloads-
5672538.html
I have a Macbook pro running OSX Mavericks that I'm attempting to setup for Android development.
I downloaded the standard version of Luna Eclipse.
I then downloaded and installed Java 7.
I then attempted to open Eclipse and it wanted to download a Java 6 SE?(I think) version which it did and installed.
Then it told me Version 1.60_65 of the JVM is not suitable for this product. Version 1.7 or greater is required.
What else do I have to install/upgrade?
The issue is that Eclipse wants Java 7 ('Version 1.7'), but OS X demands that you have Java 6 ('Version 1.6') installed in order to use Java applications. So, Eclipse starts, sees Java 6, then quits and tells you to upgrade to Java 7. If you use Java 7, OS X won't let you start Eclipse.
The fix is to install Java 7 (which you already have), uninstall Java 6, then symlink Java 7 to where OS X expects to find Java 6.
As per this link, the procedure goes like this:
# Remove Java 6
sudo rm -rf /System/Library/Java/JavaVirtualMachines/
sudo rm /private/var/db/receipts/com.apple.pkg.JavaForMacOSX*
sudo rm /usr/bin/java
sudo rm /Library/Java/Home
# Symlink Java 7
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home/bin/java /usr/bin/java
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home /Library/Java/Home
(I'm not at my Mac to try this, but I had to do this to get Eclipse to work myself)
Make sure you have the latest java version. Then you can download Eclipse ADT from: http://developer.android.com/sdk/index.html which will include eclipse and android SDK.
You can also download Android Studio instead of Eclipse, android sdk is also included in the package.
After all open android SDK Manager and download api-s that you need.
Installed Java SE 1.7.0u10 from Oracle w/ their installer package
Downloaded and unpacked Eclipse Juno (4.2.1)
Double click Eclipse purple icon and get OS X alert prompt with error message:
To open "Eclipse," you need a Java SE 6 runtime. Would you like to
install one now?
(in terminal) which java - /usr/bin/java
ls -l /usr/bin/java - /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
(in Finder) Double click eclipse alias (included when unpacked download) - Terminal launches, /Applications/Eclipse/Eclipse.app/Contents/MacOS/eclipse ; exit ; and Exclipse launches without OS X alert prompt.
I've tried modifying the Eclipse app bundle plist to point the -vm key to /System/Library/Frameworks/JavaVM.frameworks/Versions/Current/Commands/java, but I feel like I probably shouldn't have to do this.`
I'd like to know how to get Eclipse to launch by just double clicking on the Application package. It's such a small thing to bug me... :o)
The best answer is to fix the Java 7 installation as shown here :
https://stackoverflow.com/a/19594116
Simple to do and I have confirmed it works on Mavericks. With this fix, you can launch your app from the launchpad as usual. If you upgrade your JDK, you will have to reapply the fix to the new installation.
I had JDK 7 installed and I solved this issue for eclipse Kepler by running eclipse from the terminal instead of the finder.
./eclipse
Just thought to share.
Update 1
For the sake of completeness, if you want to run it from Finder as well, you can wrap the ./eclipse command into a .command file and run it from Finder (so that you don't have to open a terminal)
The following lines should do the job (don't forget to replace "your-full-eclipse-path" with the eclipse path on your machine)
#!/bin/sh
/your-full-eclipse-path/eclipse
After that, give execute permission to the eclipse.command file you just created
chmod +x eclipse.command
I found the answer over on Ask Different
It's an ugly hack, but works perfectly.
posted on this page: Mountain Lion with Java 7 only
To trick OS X to accept Java 7 instead of proposing to install Java 6 a simple symlink is enough:
sudo mkdir /System/Library/Java/JavaVirtualMachines
sudo ln -s /Library/Java/JavaVirtualMachines/1.7.0.jdk /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
Most Java Programs will run with this little hack without the need to install Java 6. OS X's Java Preferences (and maybe some others) will not as it seems to explicitly check the version of the JVM when it is started.
script above can fix my problem.
Hoping you are using 64-bit of Java SE 1.7.0 and so advising the following.
go to Eclipse->Preferences...->Java->Installed JREs
click Add...
Select Standard VM
paste /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home into JRE home
Change the JRE name to something useful like Java SE 7
Click Finish
Check the check-box next to your newly created JRE.
You would need a restart.
For what it's worth, the Eclipse team seems to have worked around it by replacing their dlopen()-based method with a CFBundleCreate()-based one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361
In case anybody has the same problem in their code that launches Java and does not want to resort to Apple-only APIs, I found an easier work-around: before dlopen()ing $JRE_HOME/lib/server/libjvm.dylib, make sure to open dlopen() $JRE_HOME/lib/jli/libjli.dylib. Then it won't ask to install Java 6.
Can you imagine that? You have to install a JDK 1.6 to get eclipse ran properly, even if you already have jdk 1.7 installed, and set the JAVA_HOME properly.
To resolve your issue, you just need to download the jdk1.6 from http://support.apple.com/kb/DL1572?viewlocale=en_US, and install it, later you will be able to run eclipse, and you can set the JAVA_HOME to JDK1.7, and you will be able to find the JDK1.7 from eclipse "Preferences".
All these hacks does not work on mac Mavericks,
But a simple and efficient solution is found here
it worked with me like a charm.
Note: a drawback of this solution is when you check your java version using "java -version" command, it will read Java 1.6
open /Library/Java/JavaVirtualMachines/jdkXXXXX.jdk/Contents/Info.plist
settting(<string>BundledApp</string> is usefull!):
<key>JVMCapabilities</key>
<array>
<string>JNI</string>
<string>BundledApp</string>
<string>WebStart</string>
<string>Applets</string>
<string>CommandLine</string>
</array>
I had the exact same message when setting up a new mac and trying to run eclipse 4.2.2 with only Java SE 7 installed (as part of JDK 7u17).
In order to be able to successfully launch Eclipse I had to let OSX download and install Apple's Java SE 6 runtime first before installing the latest JDK.
After installing the JDK, the command java -version correctly shows:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Trying to solve the problem the other way around didn't work -- i.e. installing JDK 7u17 first before installing Java SE 6 as suggested in the message.
I had the exactly same problem some days ago and I solved it today. Just installed this http://support.apple.com/kb/dl1572
And after that, when I opened the eclipse the OSX installed some java update and opening eclipse by Eclipse.app started working.
Hope it works with you too.
If you'd like to install Java 6 JDK only (no Java 7 JDK/JRE, no Java 6 JRE only), install the Apple OSX Java DMG (at time of writing, this was http://adcdownload.apple.com/Developer_Tools/java_for_os_x_2013003_developer_package/java_for_os_x_2013003_dp__11m4406.dmg).
You still won't be able to start Eclipse. Make a directory JavaVirtualMachines under /System/Library/Java. And then make an Alias of the java version folder at /Library/Java/JavaVirtualMachines and rename the alias 1.6.0.jdk and copy that alias to /System/Library/Java/JavaVirtualMachines/
After finished, you will have an Alias at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk that points to the Java install directory at */Library/Java/JavaVirtualMachines/1.6.0_XX-XXX-XXX.jdk*
Install latest JDK from Sun, it installs into /Library/Java/JavaVirtualMachines/, e.g. /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk
sudo mkdir /System/Library/Java/JavaVirtualMachines
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/ /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
========= this trick used to work on Mountain Lion, but not on Maverick 10.9 somehow ============
Tried this again on Maverick, it does not work anymore. I also tried to change eclipse app plist and eclipse.ini (by adding -vm or ), does not work either.
Some people suggested that this is caused by Eclipse binary prepared using Apple 1.6 appbundler instead of Oracle java7 appbundler: Application is using Java 6 from Apple instead of Java 7 from Oracle on Mac OS X?
For now, please just type the eclipse from command line, which works fine with JAVA_HOME set to Java 7 (/usr/libexec/java_home command will tell you)
How to Make Eclipse Run on OS X 10.9 Mavericks
Attempting to launch various Eclipse versions after the Mavericks upgrade pops up a dialog with this message:
To open "Eclipse.app" you need a Java SE 6 runtime. Would you like to install one now?
It turns out that Java 7 is disabled by default in OS X 10.9.
This is easily verified as follows:
$ java --version
No Java runtime present, requesting install.
The solution is to install the latest supported Java version from Apple support: Java for OS X 2013-005 (http://support.apple.com/kb/DL1572)
As of 10/15/13 this would be Java SE 6 1.6.0_65.
Post Date: Oct 15, 2013
File Size: 63.98 MB
After the install, Eclipse will run as expected from the Dock, the Finder, or the Terminal without any tricks, hacks, or work-arounds.
I wanted to run Eclipse itself with Java 7. As I have a couple of plugins that do not work without it. For me neither solution worked for 10.9, but I found a workaround. The main idea is that you start eclipse with java -jar launcher.jar and provide a couple of magic properties and then it starts. This guy provided the command line script in comments that works for me:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361#c25
I found the same problem (Mac OS X 10.9.2, Java 1.7.0_53b13, Eclipse Kepler). The workaround was quite easy:
Find the executable in Finder (CMD+Click on Eclipse's icon in the Dock)
Remove the icon from the Dock
CTRL+Click on the executable in Finder
ALT+Open (to allow the execution of a non-signed application)
Eclipse opens normally and without any problem
Re-dragged the program onto the Dock
I had this problem and found that I did not have JDK installed on my Mac. Once I did that, Eclipse starts normally.
I had same problem.
First of all ; JDK(java development Kit) and JRE(Java Runtime Environment) are different things. It was confused by people
In order to install eclipse yo should install latest JDK . So
Visit
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Download suitable version for your mac
You can check your version now ; it won't be 1.6 anymore
Try to install eclipse again , see it works.
Good luck!..
I want to install a specific JDK (the latest for example). For this, I went to the JDK download homepage: http://java.sun.com/javase/downloads/index.jsp.
I looked for a Mac version, but I'm a bit surprised to only see downloadable versions for Linux, Windows and Solaris...
Here's the message for Mac:
"Apple Computer supplies their own version of Java. Use the Software
Update feature (available on the Apple menu) to check that you have
the most up-to-date version of Java for your Mac."
OK BUT... when I update Java with Mac I have a JRE and not a JDK...
I don't understand why a JDK version doesn't exist that is easily downloadable/installable (like a jar to unzip?) for Mac...
In a comment under #Thilo's answer, #mobibob asked how to set JAVA_HOME in your .bash_profile on a Mac. Answer:
export JAVA_HOME=`/usr/libexec/java_home`
This will dynamically assign to JAVA_HOME the location of the first JDK listed in the "General" tab of "Java Preferences" utility.
See Apple Technical Q&A 1170: https://developer.apple.com/library/content/qa/qa1170/_index.html
EDIT:
If you prefer parentheses to backticks for command substitution, this also works:
export JAVA_HOME=$(/usr/libexec/java_home)
As the message says, you have to go to Apple, not Sun, for Java on the Mac. As far as I know, Apple JDK 6 is installed by default on Mac OS X 10.6 (Snow Leopard). Maybe you need to install the developer tools from your Mac OS X installation DVD (the dev tools are an optional install from the OS DVD).
See: http://developer.apple.com/java/
NOTE This answer from 16 Oct 2009 is now outdated; you can get the JDK for Mac OS X from the regular JDK download page on Oracle's website now.
For people using any LION OS X 10.7.X
They uploaded Java SE 6 version 1.6.0_26 available here
http://support.apple.com/kb/dl1421
I bought a MacBook Pro yesterday (Mac OS X v10.8 (Mountain Lion)) and there is no JDK installed by default...
As well as javac, I also found it didn't have packages such as SVN installed. It turns out you can get everything from the Apple developer page (you will need to register with your AppleID). SVN is part of the "Command Line Tools" package.
This is what happens on a fresh MacBook:
Hopefully this will help out other newbies like me ;)
The explanation is that JDK is a bit specific and does not contain the library tools.jar. For my development, I need this library and Mac's JDK doesn't provide it:
(Cf. http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html)
tools.jar does not exist. Classes usually located here are instead included in classes.jar. Scripts that rely on the existence of tools.jar need to be rewritten accordingly.
It sucks!
The easiest way is to use Homebrew.
Install Homebrew and then:
brew tap caskroom/versions
brew cask install java7
You can list all available versions using the following command:
brew cask search java
Mac comes with the JDK, for more information check:
http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html
Compiling with -source 1.5 -target 1.5 (in a JDK 6 environment) will honor only language elements that were in 1.5 and prior. Great. But there were no language changes in 6 anyway. Problem with this approach (on Mac with 1.6) is that using classes that came AFTER 1.5 will still compile because they exist in the rt.jar. So one could run in a 1.5 env and get a class not found exception with no prior warning when compiling. I found this out the hard way with javax.swing.event.RowSorterEvent/Listener. Both entered "Since 1.6" but are not caught with -source 1.5
If you installed brew, cmd below will be helpful:
brew cask install java
As of Mac OS X v10.6 (Snow Leopard), you can run Java 6 in 32-bit mode on either 32-bit or 64-bit Intel processor equipped Macs.
If you cannot upgrade to Snow Leopard, Soy Latte is a pre-compiled version of Java 6 for Intel 32-bit.
There are various tricky issues with having multiple versions of Java (Apple's own Java 6 and Oracle JDK 7 or even 8) on one's Mac OS X system, and using different versions for different applications. I spent some time writing up my experience of my experience of installing and configuring various versions of JDK on Mac OS X 10.9.2.
In 2022, give a try to sdkman, is better than brew
curl -s "https://get.sdkman.io" | bash
then open a new shell and try list to see what you could install ;-)
sdk list java
At time of writing you could use:
sdk install java 17.0.1-tem
Check this awesome tool sdkman to manage your jdk and other jdk related tools with great ease!
e.g.
$sdk list java
$sdk install java <VERSION>
Since most answers are out of date, here's what works as of end of 2018 under the assumption that
You want to install the GPL version of OpenJDK.[0]
You do not want to install Homebrew
In that case, grab the desired version from one the many available, freely usable OpenJDK editions, e.g.:
AdoptOpenJDK
Amazon Corretto (Great for production, includes backports)
Oracle GPLv2 OpenJDK
Some of these include installers, but if not you can do the following. Assuming here version 11.0.1 for Mac. In your favorite shell, run:
tar -xzf openjdk-11.0.1_osx-x64_bin.tar.gz
sudo mv jdk-11.0.1.jdk /Library/Java/JavaVirtualMachines
# Fix owner and group
sudo chown -R root:wheel /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk
# (Optional) Check if the new JDK can be found
/usr/libexec/java_home
=> /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
[0] Note that the Oracle branded JDK has significant licensing restrictions allowing you its use basically only for testing, i.e., not for production. If you do not have a support agreement with Oracle, then it seems risky to me to use their JDK, especially since the differences to OpenJDK are minimal.
Edit: added more choices
I think this other Stack Overflow question could help:
How to get JDK 1.5 on Mac OS X
It basically says that if you need to compile or execute a Java application with an older version of the JDK (for example 1.4 or 1.5), you can do it using the 1.6 because it is backwards compatible. To do it so you will need to add the parameter -source 1.5 and/or -target 1.5 in the javac options or in your IDE.
JDK is the Java Development Kit (used to develop Java software).
JRE is the Java Runtime Environment (used to run any .jar file 'Java software').
The JDK contains a JRE inside it.
On Windows when you update Java, it updates the JRE automatically.
On Mac you do not have a JRE separated you have it, but inside the JDK, so when you update Java it will update your JRE which is inside your JDK;
it doesn't install an JDK for you. You need to get it from somewhere else.
As a rule you cannot install other versions of Java on a Mac than those provided by Apple through Software Update. If you need Java 6 you must have a 64-bit Intel computer. You should always have Java 5 and 1.4 and perhaps 1.3 installed if you have at least OS X 10.4.
If you have VERY much elbow grease and is willing to work with beta software you can install the OpenJDK under OS X, but I don't think you want to go there.