• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdk7 & jdk6 coexist on windows XP

 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My windows XP computer has jdk 6.
I like to install jdk7 so that both jdks coexist / work.
Is there any caveats I should be aware of?

C:\>java -version
java version "1.6.0_19"
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) Client VM (build 16.2-b04, mixed mode, sharing)

I use the latest Eclipse as IDE.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
albert kao
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 install jdk7 and the environment becomes:
C:\>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b115)
Java HotSpot(TM) Client VM (build 20.0-b02, mixed mode, sharing)

Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:
\Program Files\Windows Imaging\;C:\Program Files\TortoiseSVN\bin;C:\Sun\SDK\bin

How to change the default jdk to 6 when using the command line?
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change the path to point to your JDK 6 installation.
 
albert kao
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wouter Oet wrote:Change the path to point to your JDK 6 installation.



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

C:\>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b115)
Java HotSpot(TM) Client VM (build 20.0-b02, mixed mode, sharing)

C:\>"C:\Program Files\Java\jdk1.6.0_19\bin\java" -version
java version "1.6.0_19"
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) Client VM (build 16.2-b04, mixed mode, sharing)
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't add it but change it. Like I said only one can be on the path. So remove C:\Sun\SDK\bin (which I assume is a JDK 7 install).
 
albert kao
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wouter Oet wrote:Don't add it but change it. Like I said only one can be on the path. So remove C:\Sun\SDK\bin (which I assume is a JDK 7 install).



I need to put the jdk6 at the beginning of the path.
How to use the jdk7?

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;
default JDK is 7

Path=C:\Program Files\Java\jdk1.6.0_19\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:
\Program Files\Windows Imaging\;C:\Program Files\TortoiseSVN\bin
default JDK is 6

C:\>C:\Sun\SDK\bin\java -version
'C:\Sun\SDK\bin\java' is not recognized as an internal or external command,
operable program or batch file.

C:\>dir C:\Sun\SDK\bin
Volume in drive C is Local Disk
Volume Serial Number is 1EAC-BC67

Directory of C:\Sun\SDK\bin

09/08/2010 11:48 AM <DIR> .
09/08/2010 11:48 AM <DIR> ..
09/08/2010 11:48 AM 2,532 appclient.bat
09/08/2010 11:48 AM 1,177 asadmin.bat
09/08/2010 11:48 AM 818 asant.bat
09/08/2010 11:48 AM 690 asapt.bat
09/08/2010 11:48 AM 1,355 asupgrade.bat
09/08/2010 11:48 AM 474 capture-schema.bat
09/08/2010 11:47 AM 27,280 cliutil.dll
09/08/2010 11:48 AM 526 jspc.bat
09/08/2010 11:48 AM 522 package-appclient.bat
09/08/2010 11:48 AM 847 schemagen.bat
09/08/2010 11:48 AM 1,360 verifier.bat
09/08/2010 11:48 AM 863 wscompile.bat
09/08/2010 11:48 AM 863 wsdeploy.bat
09/08/2010 11:48 AM 840 wsgen.bat
09/08/2010 11:48 AM 855 wsimport.bat
09/08/2010 11:48 AM 816 xjc.bat
16 File(s) 41,818 bytes
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
albert kao
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My default JDK is 6 and it coexists with jdk7.
Please help to solve the following jdk 7 compile error.
Path=C:\Program Files\Java\jdk1.6.0_19\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:
\Program Files\Windows Imaging\;C:\Program Files\TortoiseSVN\bin;C:\Sun\SDK\bin

C:\javadev\Backup\src>"C:\Program Files\Java\jdk1.7.0\bin\java" -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b115)
Java HotSpot(TM) Client VM (build 20.0-b02, mixed mode, sharing)

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)

C:\javadev\Backup\src>echo %CLASSPATH%
.;C:\Program Files\QuickTime\QTSystem\QTJava.zip

C:\javadev\Backup\src>dir C*.java
Volume in drive C is Local Disk
Volume Serial Number is 1EAC-BC67

Directory of C:\javadev\Backup\src

25/10/2010 12:45 PM 8,467 Copy.java

Copy.java:
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't run .java (source) files. You must first compile those (with javac). Then, with the right class path, all you need to run is "Copy", not "Copy.java".
 
A feeble attempt to tell you about our stuff that makes us money
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic