How to install Java 7 next to Java 6

java

I am using a MackBook Pro with Mac OS X 10.8.2. I currently have Java 6 installed:

wdb-laptop:~ wdb$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

I would like to install Java 7 to play with JavaFX, however, all of my apps for work are still on Java 6. So I would like to install Java 7 "on the side". Is his possible? If so, how? I want to make sure I will not loose my Java 6 installation if I run the .dmg from Oracle.

Best Answer

The oracle Java 7 does not remove the Apple supplied Java 6. It does however change /usr/bin/java to start the Oracle Java.

To start a jar with Java 6 instead of just using java on the command line put in the full path to the java i.e. /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java