issue setting up eclipse on mac osx mavericks - java

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.

Related

macOS - How to install Java 17

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

No Java Found and No JDK Found when installing NetBeans on Mac OS Big Sur

I got a tough issue when trying to installing NetBeans.
I have JDK 8 on my machine but want to use JDK 11 for NetBeans. So I installed AdoptOpenJDK 11 and set the java home path in .bash-profile.
However, I still got the "No JDK Found problem" on Mac. So I tried to remove the older JDK folder and uninstall the older java using 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/Oracle/Java
But this seems to result in a critical problem. The NetBeans installer says "No Java Found", although I've already installed AdoptOpenJDK 11, and I also tried to install Oracle JDK using their installer.
JAVA path in .bash_profile:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.11.jdk/Contents/Home
Issues when installing NetBeans:
EDIT: The NetBeans version I tried to install is 12.0. The JDK version I tried to use is AdoptOpenJDK 11 and Oracle JDK 11 (either can work for NetBeans)
I just figured out a successful installing on Big Sur.
First, please install NetBeans 12.3 instead of LTS 12.0
Second, Oracle JDK 11 seems to have some bugs when working with NetBeans. NB often quits unexpectedly and almost can't be used normally(if your NB quit unexpectedly with an auto-generated terminal command in the code block below, we are in the same case). So I use AdoptOpenJDK 11 as a workaround. Note that for myself, I deleted all the JDKs except for this one, as the expectation still occurs even though I have already configured the java path in .bash_profile.
/Library/Java/JavaVirtualMachines/jdk-11.0.11.jdk/Contents/Home/bin/java ; exit;
Thanks for all your comments and wish you a good experience with NetBeans!

Uninstalling JDK 8 on OSX

How can I cleanse my Mac of Java 8 -- jdk, not jre or plugin, which I don't care about? I need to downgrade to jdk 7. I've found docs online but they're all about the java plugin. If I try simply installing jdk 7 (on top of 8), the 8 is still there.
You can uninstall a JDK simply by deleting the appropriate directory under /Library/Java/JavaVirtualMachines where it is installed. But note that browsers, Java Web Start and double-clickable app bundles created with Oracle's appbundler will always use the "public JRE" under /Library/Internet Plug-Ins, and that will remain as Java 8 unless you uninstall it separately.
But you may not actually need to uninstall Java 8 - the command line tools such as java and javac respect JAVA_HOME, so you can have both versions installed side by side and pick the appropriate one with /usr/libexec/java_home:
export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`
On my machine, I get the following output from terminal:
> /usr/libexec/java_home -v 1.6
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> /usr/libexec/java_home -v 1.7
/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
> /usr/libexec/java_home -v 1.8
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
Check yours and let me know.

Upgrade/install Java version in a Mac

I am on a Mac. My current Java version is "1.6.0_65". Therefore i want to upgrade it to the latest. I typed the following command on my Mac terminal.
sudo apt-get install oracle-java7-installer
The error i got is sudo: apt-get: command not found. Then i tried using yum command instead. and the error i got it sudo: yum: command not found.
1.) Is there a way to install apt-get and yum on Mac, if so how?
2.) What is the command to upgrade Java using a Mac?
Sudo apt-get is for Ubuntu or Debian, no for Mac. You only need to download java from Oracle or Apple servers and install!!
You can download this http://support.apple.com/kb/dl1573
Apple provides a Java 6 implementation for Mac OS X, based on source code from Oracle's implementation.
Oracle provides a Java 7 implementation that incorporates source code provided by Apple. Apple staff cooperate in its development.
The old URL, nice and short, redirects to Oracle's download page:
http://java.sun.com/
From there navigate to the Java SE download page. Download JRE to run Java software. Download JDK if you want to develop new Java software. Download and run an installer app.
Currently that page URL is:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Oracle also provides an early release of Java 8 for Mac OS X.

Installing Java 7 on Mac OS X: "A higher version of the JRE is already installed on this system"

When trying to install newly released Java 7 Update 6 for Mac, the installer terminates printing following error message:
A higher version of the JRE is already installed on this system
I installed Java 7 Beta before (which actually has been only an internet plugin), which had some problems with updating.
Deleting Java 7 Internet Plugin folder solves the problem (recommended way of uninstalling the beta), the installer is now able to run successfully.
Run
sudo rm -rf '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin'
or delete /Library/Internet Plug-Ins/JavaAppletPlugin.plugin on your own.
Do not forget to install JDK 7 afterwards, you will not be able to select Java 7 otherwise.

Categories