You can perfectly install them together. You can usually specify which java version you want to use in your IDE.
When using the commandline it can get a little more complicated because only 1 java version can be on the path.
You can overwrite the path value each time you want to use the other version or you need to write the absolute path
to the java version when you compile and run.

Wouter Oet wrote:You can perfectly install them together. You can usually specify which java version you want to use in your IDE.
When using the commandline it can get a little more complicated because only 1 java version can be on the path.
You can overwrite the path value each time you want to use the other version or you need to write the absolute path
to the java version when you compile and run.

I added jdk6 to path but the default jdk is still 7.
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:
\Program Files\Windows Imaging\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_19\bin;C:\Sun\SDK\bin

Your "java" is actually C:\WINDOWS\system32\java.exe. This is a wrapper that uses the Windows registry to determine which Java executable to actually use. Fortunately you can change this*. Press the Start button, then Run. Enter "regedit" and press enter. In the tree search for HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment. Open it in the tree to see its children. Double click "CurrentVersion" on the right and change the value to the name of one of the children (e.g. 1.6). Press OK, then try again.

Or the easy way, put the JDK folder before C:\WINDOWS\system32 on your PATH variable.

* If you couldn't you'd be screwed if you installed (older?) Oracle software. They tend (or used to?) to install a very old JRE (as old as 1.1.7!), and make it the default.

C:\javadev\Backup\src>"C:\Program Files\Java\jdk1.7.0\bin\java" Copy.java
Error: Could not find main class Copy.java
Exception in thread "main" java.lang.NoClassDefFoundError: Copy.java
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198)
Caused by: java.lang.ClassNotFoundException: Copy.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:195)