File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Execution Problem

 
Rahul Bajaj
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Rahul Bajaj
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,It worked. I am able to execute now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic