Configuring OS X Java to Recognize rt.jar
Posted July 5th, 2011 by Aaron
If you’re a Java developer, you’ve probably noticed by now that OS X’s version of Java does not include a version of rt.jar (the Java Runtime Environment JAR). However, you will occasionally have a need to have this file available to various Java applications, so here’s a quick and (relatively) easy fix that has worked for me:
The OS X equivalent to rt.jar is called classes.jar and it is located in /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes. Assuming that $JAVA_HOME will be mapped to /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK, you can then point any application looking for /jre/lib/rt.jar to the classes.jar by executing the following commands in Terminal:
-
cd /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
-
sudo ln -s ./Home jre
-
cd jre/lib
-
sudo ln -s ../../Classes/classes.jar rt.jar
That’s it! Just be aware that any time a Software Update updates OS X’s Java, you will likely need to re-execute these commands.