TOTB
TOTB

Reputation: 23

java -version tells me 8 but jdk is 1.7 - OSX 10.9.x

Something I don't understand - I'm on OSX 10.9.5 and when I run java -version at the terminal, I get:

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

But in my /Library/Java/JavaVirtualMachines/ dir I see 3 JDKs:

Eclipse uses jdk1.7.0_76.jdk. I remember installing Java 7 for some personal dev projects in Eclipse, but I don't recall ever installing Java 8. So why would java -version say I'm running 8? And how can it if no jdk exists for Java 8 in that directory?

Confused. TIA.

Upvotes: 2

Views: 1214

Answers (2)

l'L'l
l'L'l

Reputation: 47169

The version you are questioning is actually the Java Runtime Environment (JRE) version, not the Java Developer Kit (JDK) version; they are two different things. You are running Java 8 (JRE), although you can selectively choose another runtime if there is one available.

If you want to see all of the versions of Java you might currently have:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    1.8.0_45,             x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
    1.6.0_65-b14-466.1,   x86_64:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-466.1,     i386:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

To see which one is currently running as default:

$ which java ; java -version
/usr/bin/java
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

To see which JDKs are installed:

$ ls /Library/Java/JavaVirtualMachines/
jdk1.8.0_45.jdk

The Java Runtime Environment (JRE)

The JRE allows you to run applications written in the Java programming language. Like the JDK, it contains the Java Virtual Machine (JVM), classes comprising the Java platform API, and supporting files. Unlike the JDK, it does not contain development tools such as compilers and debuggers.

The Java Development Kit (JDK)

The JDK is a development environment for building applications, applets, and components using the Java programming language. The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the Java platform.

Since Eclipse relies on the tools within the JDK they would most definitely be using one of your installed JDKs, for it couldn't work just using the JRE.

Upvotes: 4

Alaa Abuzaghleh
Alaa Abuzaghleh

Reputation: 1009

in you .path_profile folder export the JAVA_HOME to your JDK8 folder, java -version is a result of you JVN as it seem to me put you java_home still point to JDK1.7 do the following

$ vim .bash_profile 

export JAVA_HOME=YOUR_JDK8_PATH 

$ source .bash_profile

Upvotes: 0

Related Questions