0

I am having issues with my Java path.

I have installed the latest version of Java 1.7.0_51. When I open the Java control panel it tells me "Your system has the recommended version of Java."

Java Control Panel

However when I go to terminal and type java -version I get

java version "1.6.0_32"

So after searching around I came across this SO Question which tells me that my Java home environment variable needs to be set.

I then opened the bash_profile file and added the below line to the top of the file, above my Python path info.

export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_51`


# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

NOTE: I have tried this with both -v 1.7.0_51 and -v 1.7

I save the file and recheck in terminal but it is still showing

java version "1.6.0_32" 

when I restart Terminal I do however see

Last login: Wed Feb 19 23:32:19 on ttys000
Unable to find any JVMs matching version "1.7".
localhost:/ user$

Note: Unable to find any JVMs matching version "1.7".

So it is trying to look for my 1.7, but just not finding it.

What am I doing wrong?

Community
  • 1
  • 1
Deepend
  • 4,057
  • 17
  • 60
  • 101

2 Answers2

1

Check whether there is an old version existed in the path

echo $PATH

Then set the java 1.7 bin directory.

export PATH=/usr/libexec/java_1.7_home/bin:$PATH

Then try to type in "java -version" in terminal to check the version

yushulx
  • 11,695
  • 8
  • 37
  • 64
  • When I type echo $PATH I see my python path info. e.g. "/Library/Frameworks/Python.framework/Versions/2.7/bin:" The second instruction (copy-pasted exactly) has no effect when I check the version. I also restarted Terminal to see if it would work. – Deepend Feb 20 '14 at 11:07
  • You can't just copy it. It's an example. You have to use your own JDK bin directory "export PATH=/YOUR_JDK_PATH/bin:$PATH" – yushulx Feb 21 '14 at 01:19
  • I think I tried that this morning, afterwards. I'll check again when I'm back at the computer tomorrow, thanks again – Deepend Feb 21 '14 at 01:23
0

Ok, I think this must be specific to me. As above the Java control panel was saying that java 7 was installed. Also when i tried

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version

I would get

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)

But no mater what way I installed the JDK it would not work. It just didn't seem to appear anywhere on my machine. I still don't know why, but uninstalling (by simply deleting the 1.6 folder) the existing Java 6 from my machine and once again installing Java 7 JDK eventually fixed it.

Please give the up-votes to @diaz994 above.

Deepend
  • 4,057
  • 17
  • 60
  • 101