0

I am trying to run an application (on MacOSX) that relies on Java. Docs are telling me that I need to update from Java 1.6 to 1.7. I then found, downloaded and installed java 7 from Java.com, but I'm still getting java version error when running app. when I enter 'java -version' into terminal it tells me I am still running 1.6?

I'm sure there is a logical explanation for this, but at the moment I feel Like I am in the twilight zone. What is the current version, 1.7 or 7? Why is it that in System Preferences it says I have Java 7 installed, but 'java -version' says I have 1.6?

Help!

Jason
  • 1,957
  • 2
  • 20
  • 34
  • Possible duplicate of [Installed Java 7 on Mac OS X but Terminal is still using version 6](http://stackoverflow.com/questions/12757558/installed-java-7-on-mac-os-x-but-terminal-is-still-using-version-6?rq=1) – ratiaris Aug 22 '14 at 11:38
  • Ben, I think you have misred my question.. the versions where right, your edits imply a misreading of the question, but thanks anyway. – Jason Aug 22 '14 at 11:39
  • Your question is very unclear then. I'm reading it as asking why your Terminal references Java 6 when you need Java 7 (ignore the '1.' bit, that's been irrelevant since Java 5 / 1.5 was introduced). If you're asking about 1.7 vs 7, there's no difference. – Ben Aug 22 '14 at 11:40
  • Just to clarify.. I currently have 1.6 installed if I check via the terminal. I installed version 7 from Java.com. but oracle.com has the latest as version 1.7, so which is the latest? 7 from java.com. or 1.7 from oracle.com? – Jason Aug 22 '14 at 11:41
  • I guess I was asking both. Sorry.. should have seperated the questions more. I guess you are saying that 7 and 1.7 are the same thing (hmmm.. wierd, but only explanation I guess). Now just a case of getting terminal java pointing to 7.. thanks again! – Jason Aug 22 '14 at 11:43
  • English is not my native language, so misunderstading can happen - thouhg I try my best to avoid it. It seemed to me your problem was actually similar, hence my initial comment. And among the posted answers was indeed @Ben's. – ratiaris Aug 22 '14 at 11:49
  • Yep, I did misread part of your post, sorry about that ;-) Indeed 7 and 1.7 are the same - which is confusing, I agree. – ratiaris Aug 22 '14 at 11:52
  • You don't mention the app in question, but if it's a development tool, then you need to install the `JDK` and not just the `JRE`. The `JDK` can be downloaded from http://www.oracle.com/technetwork/java/javase/downloads/index.html – Anya Shenanigans Aug 22 '14 at 11:56
  • Hi Petesh.. intall of the JDK did the trick. I installed JDK Vesion 7, and 'java -version' now shows 1.7 (still wierd, but anyway). So I guess System Preferences is showing the version for the JRE, and terminal is showing the verson for the JDK(?). If you can post your advice re the JDK as an answer I can tick it off. Thanks!! – Jason Aug 22 '14 at 12:14

1 Answers1

0

I just have this in my bash profile:

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

... This should ensure that your Mac references Java 7 where applicable. Per the Apple docs:

The /usr/libexec/java_home tool dynamically finds the top Java version specified in Java Preferences for the current user. This path allows access to the bin subdirectory where command line tools such as java, javac, etc. exist as on other platforms. The tool /usr/libexec/java_home allows you to specify a particular CPU architecture and Java platform version when locating a $JAVA_HOME.

(From Technical Q&A QA1170: Important Java Directories on Mac OS X)

EDIT re bash profiles: If you don't know about shells and their configuration, you have a little work ahead ofyou. However, Nathaniel Landau's post, My Mac OSX bash profile may well help you.

Ben
  • 7,548
  • 31
  • 45
  • If you don't know about shells and how to configure them, that's a big topic. However, simple Google searches will help you. This link summarises creating / editing your `.bash_profile`: http://natelandau.com/my-mac-osx-bash_profile/ – Ben Aug 22 '14 at 12:27