This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Execution Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Execution Problem" Watch "Execution Problem" New topic
Author

Execution Problem

Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
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)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

This line:

makes it sound like you compiled your class with JDK 1.5, but are trying to run it with JDK 1.4.
What is the out put of these commands:


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
Output of java -version is


I:\>java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
and for javac -version o/p is

javac 1.5.0_02

which means I have 1.3 and 1.5, what can I do to resolve?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

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 ]
Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
Thanks,It worked. I am able to execute now.
 
GeeCON Prague 2014
 
subject: Execution Problem