Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Updating Java completely with minimal breakage?

I downloaded the latest Java Development Kit from Oracle, and its installer neatly tucked the file away at...

/Library/Java/VirtualMachines/jdk1.7.0_40.jdk.

Which is a nice place for it. Except the Java the command line is using is located at...

/System/Library/Java/VirtualMachines/1.6.0.jdk.

according to java -version. And I want to fix that.


There's more difference between them than the names, unfortunately. The 1.6.0 version bundle has internal folders of Classes, Commands, and Libraries, and a Home folder which contains the more unixy bin, lib, and man folders. By contrast, the 1.7.0 bundle has neither Classes, Commands, nor Libraries, but its Home folder also contains db and jre folders.


To see why this is a problem, I present /System/Library/Frameworks/JavaVM.framework:

drwxr-xr-x 10 root wheel 340 Sep 25 15:26 .

drwxr-xr-x 135 root wheel 4590 Sep 25 04:49 ..

lrwxr-xr-x 1 root wheel 27 Sep 25 15:26 Classes -> Versions/CurrentJDK/Classes

lrwxr-xr-x 1 root wheel 28 Sep 25 15:26 Commands -> Versions/CurrentJDK/Commands

lrwxr-xr-x 1 root wheel 27 Sep 25 15:26 Frameworks -> Versions/Current/Frameworks

lrwxr-xr-x 1 root wheel 24 Sep 25 15:26 Home -> Versions/CurrentJDK/Home

lrwxr-xr-x 1 root wheel 23 Sep 25 15:26 JavaVM -> Versions/Current/JavaVM

lrwxr-xr-x 1 root wheel 29 Sep 25 15:26 Libraries -> Versions/CurrentJDK/Libraries

lrwxr-xr-x 1 root wheel 26 Sep 25 15:26 Resources -> Versions/Current/Resources

drwxr-xr-x 11 root wheel 374 Sep 25 15:26 Versions


Where do I point those symlinks so they don't break Java?


Also, in the /System/Library/Frameworks folder, I have the following frameworks:

JavaDTWGeneration, JavaDirectToWeb, JavaEOAccess, JavaEOApplication, JavaEOControl, JavaEODistribution, JavaEOGeneration, JavaEOInterface, JavaEOInterfaceSwing, JavaEOProject, JavaEORuleSystem, JavaEOTool, JavaFoundation, JavaFrameEmbedding, JavaJDBCAdaptor, JavaJDNIAdaptor, JavaScriptCore, JavaWOExtensions, JavaWOJSPServlet, JavaWebObjects, JavaWebServicesClient, JavaWebServicesGeneration, JavaWebServicesSupport, and JavaXML beside JavaVM.


It's kind of a mess. Does everyone else have all of these, or did my brief fling with WebObjects left me with a lot of excess baggage? What can I afford to break?


Let's just say that ls -lRa /System/Library/Frameworks/Java* > ~/Downloads/JavaBoilover.txt is ugly.

MacBook Pro, OS X Mountain Lion

Posted on Sep 26, 2013 6:13 AM

Reply
2 replies

Sep 26, 2013 2:49 PM in response to Territan

FWIW,


java -version


will always show you the Java SE 6 info. To wit:


java version "1.6.0_51"

Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-10M4509)

Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)


To get the Java SE 7 info, you need to run this:


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


on my machine, that returns:


java version "1.7.0_40"

Java(TM) SE Runtime Environment (build 1.7.0_40-b43)

Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

Jan 19, 2014 6:56 PM in response to Territan

What I ended up doing is modifying the .profile file in the user home directory. I inserted the following lines to set the environmental variables JDK_HOME, JRE_HOME, and JAVA_HOME as well as place the Java libraries properly in the PATH environmental variable. This was done after loading the JDK version of the Java update. It appears that the Oracle update procedure only updates the JRE for the browser plugins. It also appears that the Java item in the conrol panel only affects the Java plugins.


JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home"

# JAVA_HOME=`/usr/libexec/java_home`

JDK_HOME=$JAVA_HOME

JRE_HOME=$JAVA_HOME/jre

export JAVA_HOME

export JRE_HOME

export JDK_HOME

PATH=${JAVA_HOME}/bin:${PATH}

export PATH


If you put these lines in /etc/profile, it will take place for all users.


To see where your java executables are located, enter the line

which -a java

The executables in /usr/bin point to the old Apple installations.


$ which -a java

/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java

/usr/bin/java

$ ls -l /usr/bin/java

lrwxr-xr-x 1 root wheel 74 Oct 17 22:11 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Updating Java completely with minimal breakage?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.