What is my real Java version on macOS? - java

I use macOS Sierra. When I do:
java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
it seems that my java version is 1.6.0.
But when I look at System Preferences I find that my version is Java 8 Update 144. I want to use an R package that needs Java >=8.0. What have I done wrong?

The Java found in your command line is the one used to compile when using command line, first, try export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) then check if the correct version shows up using java -version if not reinstall the newest java and run the command again

Related

centos using older version of java

I want to install open office in my centos linux and as part of the requirement is jdk 11.0.2 version.
I installed new version of java JDK 11.0.2 however when I use the command java -version it is still showing that it is using old version of java.
java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
i created the file /etc/profile.d/jdk11.sh and ran the command below
"source /etc/profile.d/jdk11.sh"
the file contains
export JAVA_HOME=/usr/local/jdk-11.0.2
export PATH=$PATH:$JAVA_HOME/bin
Given that you are using centOS:
try the following command:
sudo update-alternatives --config java
It should show you the list of available Java versions in your system. You can switch using the numbers shown in the result of the command.

Unable to execute jshell from Mac Terminal

I am currently using java 1.8 on my Mac Sierra.
java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
Now I want to run "jshell" for executing simple java commands right from the terminal. But I ended up with the following error message -
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/jshell" (-1)
What is the workaround do I need to do for avoiding this error message ?
As pointed out by #Elliott, you need to download and install Java-9 for working with jshell.
Once you have set the environment variable to make use of the /jdk../.../bin directory. You can execute the command jshell on your command line to get going.

Java - Mac os x - two versions

I recently updated my java version to "Java 8 update 77".
As far as i know, this is the newest version...
My Java Control Panel prints the same information,
but when i switch to terminal to verify the java version:
java -version
it outputs:
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
When i type:
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
it prints correctly:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
So, did i anything wrong?
Why are there two different versions listed ?
Thanks and Greetings!
When Java is updated, it doesn't override the older version. It keeps the older version and also installs new version.
You have to change your $JAVA_HOME environment variable if you want to use new version.
This Link May help
Open the terminal. Type...
nano ~/.bash_profile
Search for export JAVA_HOME. When you find the line, comment it out by placing a # in front of the line.
Type on the next line...
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
assuming that is where the jdk is. Press ctrl+o, ctrl+x.
Type source ~/.bash_profile. And you should be all set.
The second option that you have written about is where you are checking the java applet plugin version which does not need to be the same as the jdk runtime environment.
To make your .bash_profile future proof, you can try this
export JAVA_HOME="$(/usr/libexec/java_home)"

How to replace java6 with java8 in Mac OSX?

I hava install java8
but java -version output:
java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
How to use latest version?
Thanks.
Check out this how-to to change your java home path to the java 8 home
Use this command to update JAVA_HOME variable:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

What is the source of the discrepancy in Java versions: Java 6 (in Terminal, Eclipse) and Java 7 (in Java Control panel)?

Eclipse complains: JRE version is 1.6.0; version 1.7.0 or later is needed to run Google Plugin for Eclipse.
In the Terminal, java concurs:
> java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
But in System Preferences \ Java \ the Java Control Panel says Your system has the recommended version of Java: Java 7 Update 51
and points to /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java.
Eclipse preferences show that the installed JRE is at:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
To point Eclipse to Java 7 (1.7.0), it's enough to change the preference:
What is the source of the discrepancy in Java versions? Is this an instance of having different PATHs between the command-line Mac and the windowed-Mac?
Edit
If I edit /usr/local/adt-bundle-mac-x86_64/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini by adding
-vm
"/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
Eclipse refuses to start.
And yet this is indeed 1.7:
> "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
If you want to be certain of the JVM that is used to run Eclipse, you need to specify it in your eclipse.ini file, according to these instructions.
Installing this update might fix your problem:
http://support.apple.com/kb/dl1572

Categories

Resources