This week's giveaway is in the Testing forum. We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line! See this thread for details.
Dear All,
I am facing a weird problem.
I have windows Xp installed in C:drive and Windows 7 in E: drive.
In Xp I am using Jdk 1.4 and in win-7 i am using Jdk 6.
The problem is when I am using Windows-7, then on the Cmd prompt,
when ever I launch java -version, it shows of Jdk 1.4 .
Multi booting OS’s can have wired problems.
I did this on windows 2008.
I would think when you logon to the windows 7 machine, you would go to the control panel/ system /Environment Variable
Check if the JAVA_HOME is defined and what value it has.
Check the path variable and verify that no Java point to the C Ddrive.
How did you set the path variable? make sure that there is no overlapping, system will pickup the first parameters in the path.
Prash Singh wrote:I have properly modified the path variable.
I doubt it; if you had it'd be running the correct version. Maybe posting your PATH variable would help--I've never heard of setting the path variable one way and having the system run something completely different.
E:\>java -version
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
E:\>javac Hello.java
E:\>java Hello
Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello (Unsupported major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
E:\>type Hello.java
class Hello
{
public static void main(String args[])
{
System.out.println("Hello");
}
}
E:\>path
PATH=E:\Program Files (x86)\JavaFX\javafx-sdk1.3\bin;E:\Program Files (x86)\JavaFX\javafx-sdk1.3\emulator\bin;E:\ora
clexe\app\oracle\product\10.2.0\server\bin;E:\oracle\product\10.1.0\db_1\bin;E:\oracle\product\10.1.0\db_1\jre\1.4.2
\bin\client;E:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;E:\Windows\system32;E:\Windows;E:\Windows\System32\Wbem;E:\W
indows\System32\WindowsPowerShell\v1.0\;E:\Program Files (x86)\Java\jdk1.6.0_18\bin;E:\Program Files (x86)\Smart Pro
jects\IsoBuster;E:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;;E:\Windows\system32\gs\gs8.13\bin
I hope this will make you understand the problem better.
and If I set path at the CMD prompt, it works fine.
Please suggest what could be the problem , and how to resolve it.
Thanks in Advance
Prash Singh wrote:Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello (Unsupported major.minor version 50.0)
That means that you've compiled the class with a version 6 JDK and are running it with a lower version JRE (1.4 in this case). Either switch to a version 6 JRE or use the -target compiler flag to compile specifically for Java 1.4. You'll miss out on the nice features of Java 5.0 and beyond though, so I suggest you follow my first advice.
E:\>path
PATH=E:\Program Files (x86)\JavaFX\javafx-sdk1.3\bin;E:\Program Files (x86)\JavaFX\javafx-sdk1.3\emulator\bin;E:\ora
clexe\app\oracle\product\10.2.0\server\bin;E:\oracle\product\10.1.0\db_1\bin;E:\oracle\product\10.1.0\db_1\jre\1.4.2
\bin\client;E:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;E:\Windows\system32;E:\Windows;E:\Windows\System32\Wbem;E:\W
indows\System32\WindowsPowerShell\v1.0\;E:\Program Files (x86)\Java\jdk1.6.0_18\bin;E:\Program Files (x86)\Smart Pro
jects\IsoBuster;E:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;;E:\Windows\system32\gs\gs8.13\bin
Rob Prime is correct
I think from above given path value if go from left that is starting from PATH=E: the first available jre is 1.4.2 and later you will find jdk1.6.0_18 then in this case whenever jre 1.4.2 is reached then look for jre is haulted and jre 1.4.2 is selected as java version.
If you want to run jre 1.6 then jdk1.6 should appear before jre 1.4.2
I think that you have Oracle middle ware/components installed on the E drive, and the system is using the JRE that comes with oracle, just take the Oracle Path away to see what will happen;
E:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;E
Something must be done about this. Let's start by reading this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth