Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I thought this should be straightforward, but I un unable to successfully install and use Java 7 on OSX Lion.

I downloaded java from the Oracle site, opened the installer and followed the steps. the installer said "Installation Successful". But Java 1.7 is nowhere to be seen.

It is not found in /System/Library/Java/JavaVirtualMachines. I see only 1.6.0.jdk there

/usr/libexec/java_home -x shows only 1.6. (complete listing)

Update: I know Java 7 is installed. This is the screenshot of the Java control panel. I also see that the Java applet plugin is installed in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java I just don't know where java is installed. (I want to compile and run a Java program, so I need the path to Java 7) Java 7 *is* installed, but where?

Any idea where the installer installs Java 7?

share|improve this question
    
Well this is awkward. I had installed the JRE and was searching for Java. But still, the JRE installation does not change the default java of the system (java -version still says 1.6 even if I have JRE 1.7). I will add my own answer –  Nivas Sep 20 '13 at 22:39
add comment

3 Answers 3

Follow the instructions on the Oracle site, re: installation on a Mac that already has Java 1.6 installed.

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

/usr/libexec/java_home -v 1.7.0_06 --exec javac -version

(taken from here).

share|improve this answer
    
I don't see a 1.7 version at all. When I say /usr/libexec/java_home -v 1.7.0_40 I get the error Unable to find any JVMs matching version "1.7.0_40". From the article you had mentioned, Java 1.7 should be present in /Library/Java/JavaVirtualMachines but there is only 1.6.0.jdk there. My problem is I know Java 7 is installed on my machine, but I don't know where. (Updated question with screenshot of the Java Control Panel showing the version) –  Nivas Sep 20 '13 at 1:16
    
That article says that usually the JDK deploys to a specific location UNLESS you choose otherwise. Have you? –  Traveling Tech Guy Sep 20 '13 at 2:19
    
No. I did not change the default location. –  Nivas Sep 20 '13 at 11:37
add comment
up vote 1 down vote accepted

Well this is awkward. I had installed the JRE from this page. I should have known better, I am a Java programmer. (But I have never installed Java on a Mac, there was always an installation by default).

When you install the JRE, the installer creates a "Java Preferences" prefpane in the System Preferences and installs plugins for all browsers (except Chrome, as it is 32 bit). But it does not change the default java version in the PATH. So when you say java -version, you still get 1.6.x. This is very different from other platforms where the installer updates the default java version.

The JDK can be downloaded from here.

share|improve this answer
add comment

On my OS X Lion Oracle's JDK 1.7 is installed to this location:

/System/Library/Frameworks/JavaVM.framework/Versions/Current -> A
/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

I just updated my JDK to 1.7.0_51 and it installed to the same location.

/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/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)

UPDATE: After doing the upgrade to 1.7.0_51, now /usr/libexec/java_home lists also the 1.7 JDKs. Before that it was showing only the older 1.6 versions. Now I see that the correct JAVA_HOME is /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home.

ls -l /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
total 39768
-rw-rw-r--   1 root  wheel      3339 Dec 19 04:13 COPYRIGHT
-rw-rw-r--   1 root  wheel        40 Dec 19 04:13 LICENSE
-rw-rw-r--   1 root  wheel       114 Dec 19 04:13 README.html
-rw-rw-r--   1 root  wheel    123324 Dec 18 22:34 THIRDPARTYLICENSEREADME-JAVAFX.txt
-rw-rw-r--   1 root  wheel    173559 Dec 19 04:13 THIRDPARTYLICENSEREADME.txt
drwxrwxr-x  44 root  wheel      1496 Dec 19 04:19 bin
drwxrwxr-x   9 root  wheel       306 Dec 19 04:13 db
drwxrwxr-x   9 root  wheel       306 Dec 19 04:13 include
drwxrwxr-x  10 root  wheel       340 Dec 19 04:16 jre
drwxrwxr-x  14 root  wheel       476 Dec 19 04:17 lib
drwxrwxr-x   5 root  wheel       170 Dec 18 22:34 man
-rw-rw-r--   1 root  wheel       502 Dec 19 04:13 release
-rw-rw-r--   1 root  wheel  20039662 Dec 19 04:13 src.zip

This looks like the familiar JAVA_HOME on other platforms.

share|improve this answer
1  
Why do you have an old release of 1.7 installed? That is a huge security risk –  Ramhound Jan 29 at 20:08
    
Your formatting is a bit hard to read. –  PsychoData Jan 29 at 20:47
    
I updated the formatting and removed anything not related to the question. Thanks! –  Lion Jan 31 at 7:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.