Thank you for your response Joanne. Your clarification
Joanne Neal wrote:
You can install as many JDKs as you want. The default install directory is different for each version so you can install them in
C:\Program Files\Java\jdk1.5.0_06\ directory
and
C:\Program Files\Java\jdk1.6.0_22\ directory
or you can install them in other directories of your choosing.
helped me in successfully installing the new JDK in addition to the existing JDK 1.5.
Also, as suggested
Joanne Neal wrote:
However if you are using Netbeans, you can configure Netbeans with the available JDKs and then select whichever JDK you want to use for each
individual project. Netbeans help should tell you how to do this.
I've configured Netbeans 6.9 to the JDKs installed using the Java platform manager as described in Netbeans help.
I also want to use the command line to compile and run programs.
Joanne Neal wrote:
If you want to compile and run programs from the command line then you will need to add the bin directory to your PATH environment variable but
Windows will use the first javac/java executable it finds. Other than bu including the full path in the command line, you can't choose which javac/jave
will be used
So, I added the path to the bin directory (of the newly installed JDK 1.6) to the PATH environment variable.
I prefixed the JDK 1.6 bin directory
C:\oracle\product\10.2.0\db_1\bin;%CommonProgramFiles%\Microsoft Shared\Windows
Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;
C:\Program
Files\Java\jdk1.6.0_22\bin;C:\Program Files\Java\jdk1.5.0_06\bin
to the existing JDK, as highlighted.
However, compiling and running the program from the command line
Step 1: change to the bin directory
Step 2: change to the source directory
Step 3: compile the program
Step 4: on compilation, change to the classes directory
Step 5: list the .class files in the directory
Step 6: run the program
throws the Exception in
thread "main" java.lang.NoClassDefFoundError: TestSortStrings (wrong name: testMore/myPrograms/TestSortStrings).
A little bit of research on google showed
http://docs.oracle.com/javase/tutorial/getStarted/problems/index.html this runtime error is due to java's inability to find the .class files. Initially, I tried running the program from the source directory which threw the same exception. Given that the source & class directories are separate, steps 4,5 and 6 done as per the suggestions in the link, without success.
While the solution seems to be centered on changing the CLASSPATH
ref: http://docs.oracle.com/javase/tutorial/getStarted/problems/index.html,
http://docs.oracle.com/javase/tutorial/java/package/managingfiles.html, I'm not sure of the same given the forum's
https://coderanch.com/t/412282/java/java/we-change-tha-java-version suggestions.
My current settings in Environment variables > System variables is
CLASSPATH .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
JAVA_HOME C:\Program Files\Java\jdk1.5.0_06\
PATH C:\oracle\product\10.2.0\db_1\bin;%CommonProgramFiles%\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.6.0_22\bin;C:\Program Files\Java\jdk1.5.0_06\bin
Please help in resolving this.
Many thanks,
Sudhir