I have JavaSDK 1.4 installed at my computer. I am trying to compile and execute java prog. I am able to compile as I have set the path but during execution I am getting following error.Do I need to set classpath? If yes how?
\>java FileInputDemo test.txt Exception in thread "main" java.lang.UnsupportedClassVersionError: FileInputDemo (Unsupported major.minor version 49.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)
author and iconoclast
You have both JDK 1.4 and 1.5 installed. You're compiling with 1.5, and running with 1.4 -- that's the source of the error message. Examine your path carefully -- there may be a copy of java.exe from JDK 1.4 in a system directory like C:\WINDOWS early on your path. Make sure you're compiling and running with the same JDK -- or learn about the "-source 1.4" switch which lets JDK 1.5's compiler emit class files that work with JDK 1.4's JVM.
You can probably get away with just removing the reference to 1.3.1 from your PATH environment variable. There's instructions on how to do that in the SDK 1.5.0 Release Notes Scroll down to "5. Update the PATH variable (Optional)" [ February 17, 2006: Message edited by: Joe Ess ]