How to install JDK 8 on OS X Mountain Lion with new lambda features

Can someone help me with installing JDK 8 on Mac Mountain?

I installed java_for_os_x_2013002_dp__11m4203.dmg and I see: /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home . But I donโ€™t know what else needs to be done.

How can I make a symbolic link to the new version and so on?

I use Eclipse and maven, so I do not want a conflict with them. I am a new Mac user.

JDK 7 is already installed on my Mac, but I just want to experiment a bit with the new lambda expression.

thanks for the help

+6
source share
2 answers

If you just want to try coding with JDK8, you do not need to install it on your system. Just like the JRE in the eclipse version with Java 8 support. To get the eclipse beta build, you can create it yourself (I had problems with this) or download a pre-built version. I could not find any ready-made versions on the eclipse website, but I found it here. http://downloads.efxclipse.org/eclipse-java8/

Once you have downloaded, go to Eclipse> Preferences> Java> Installed JREs Click Add and specify the java 8 home directory. For me it was /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home.

Now create a project. Source level 1.8 is not available in the user interface, you need to change <my_project>/.settings/org.eclipse.jdt.core.prefs and make sure you have the lines below.

 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.source=1.8 

Then you will be fine.

Building eclipse is a beta, so code support does not always work with the new syntax. But it compiles and runs java 8 code :-)

+3
source

Although the EKG answer explains well what you need to do to start the Java 8 project, if you want Java 8 to be your default version on the system, you can install it as the Java home.

I (previously for maven) had the following line added to my .profile to install my Java home.

export JAVA_HOME = $ (/ usr / libexec / java_home)

Now, to install it in a specific version, I updated it to the next value

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

This allows you to install a specific version as by default, but how to update the default value for the entire system (each user who did not install it on their own) still eludes me.

Note. I know that this is not a direct answer, but this is what people will come to when they are looking for it. Alas, this is too big to write in the comments. If this โ€œanswerโ€ is better represented in another way, I would be happy to make a change.

+6
source

All Articles