简体   繁体   中英

Setting default JRE on OS X

Some background: OS X is, for the most part, foreign to me. I am trying to update to Java 8 to run something I made.

OS X 10.9.4.

It had/has Java version 1.6. I wish to update to Java 8. The subversion thereof is not specifically needed, but the most recent will do. The version I was looking at was the Oracle one. As aforementioned, my knowledge of OS X is lacking, but it is my understanding that Apple previously implemented their own, which may be the reason for some of the problems now.

It seemed to install correctly. System Preferences > Java > Java Control Panel shows the desired version - 8 11. The terminal, however, displays 1.6.

It seems on OS X there are a plethora of potential java locations - some concrete, some symbolic. In /System/Library/Frameworks/JavaVM.framework/Versions, there are several versions spanning 1.4-1.6, but nothing more recent. I cannot find any concrete location where 1.8 may reside.

How can I set the default JRE to this 1.8 update?

EDIT:

I found the 1.8 JRE in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

From the documentation :

To run a different version of Java, either specify the full path, or use the java_home tool:

% /usr/libexec/java_home -v 1.8.0_06 --exec javac -version

For more information, see the java_home(1) man page.

My current version of java resides in: Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home .

Two ways to handle this issue... but to answer your question about JRE see below.

1.) Bash Profile

If your not pointing to the JRE, your putting the JDK on your class path. For Java developers using a java tools / compiler, you want the JDK. If your looking for JRE this is more correct.

vi ~/.bash_profile (or) ~/.bashrc (to append the export)

export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre:$PATH 

I'm not sure if Apple will change their ways, but this is a safe method for individual users.

2.) Setting /Java

Configure this same address MAC -> Setting -> Java -> Java Tab -> View -> User or System -> Path 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM