Exception in thread "main" java.lang.UnsupportedClassVersionError:

Recently I've installed Oracle 9i application server into my machine. I've installed

javase 5 update 3 before. Now the problem arise after I've installed Oracle 9i.

I've set the environment path variable accordingly. Now the source files compiles accordingly with my javase 5 javac command. but problem occurs when I try to run the class file using java command. They give me the following error.

java ConnectToOracle

Exception in thread"main" java.lang.UnsupportedClassVersionError: ConnectToOrac

le (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)

for your information when I check the version of javac command using the command in the command line

javac -version

it tells me

javac 1.5.0_03

javac: no source files

Usage: javac <options> <source files>......

but when I use

java -version

it tells me

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)

which is a older version! I've also tried...

jre

Java(tm) Runtime Loader Version 1.1.8.10

Usage: jre [-options] classname [arguments]

Options:........

this is also an older jre

now my path is set as

PATH=D:\jdk1.5.0_03\bin;

but still it wont working.

BUT if I give the absolute path like this explicitly like this:

D:\jdk1.5.0_03\bin\java ConnectToOracle

the programs runs fine!

I guess my Oracle 9i has its own Jre running.

I've reinstalled jdk but that didnt solve the problem.

now please tell me how to get rid of this as I want to run the file using java command comes with jdk1.5.03 and have the latest jre!

[2554 byte] By [mr47a] at [2007-10-2 13:46:30]
# 1

Examine the directories in the PATH statement - Oracle probably inserted a directory that contains the older Java version in front of your wanted Java version.

(The error is telling you that you are trying to run a program (compiled to Java version 5) with an older Java version, which can't be done.)

Either change the PATH or use "-source 1.3" option when you compile.

ChuckBinga at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
Also, please don't duplicate your posts. Just bump the existing one if you want more replies.
ChuckBinga at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

yah! thats what i've told that oracle has put its own version of java cause it needs a jre to run. the application server.

actually I've also mentioned previously that the change in the path in environment var is not solve the problem. when working every time i have to set the path explicitly in the command line window.

mr47a at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
thanks. but have i duplicate my post? i've posted it into a different forums cause i was unsure if my problem is suiting this forum or not as i havent got a reply for a long time.
mr47a at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5

Hello,

All that you have to do is simple as use a command like this:

C:\jcarlosgarciav\tareas\dist>java -version:1.5.0_05 -jar "C:\jcarlosgarciav\tareas\dist\EjemplosDeDemostracion.jar"

Doesn't matter if you get a different version through the command "java -version"

The key part of the command is -version:<value>. I hope these can help you.

jcarlosgarciava at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6

Hi,

Can any one help me i got error while running java code from command promt.

C:\java\classes>java xactToTop 0 "C:\xactfiles\mC0301.csv" "Seg"

Exception in thread "main" java.lang.UnsupportedClassVersionError: xactToTop (

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)

I have set class path to CLASS_PATH=C:\java\classes;

i have installed jre1.5.0_04 and jdk1.5.0_04 i dont know why it's giveing this poblem

.........................................

Some one please help me

................................................

sridhar.jr@gmail.coma at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7
Please review this thread (that I found by using the search feature) http://forum.java.sun.com/thread.jspa?threadID=517933
ChuckBinga at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 8

looks as if you are having the same problem as mine. well probably you have two different version jre installed in your machine. and when you tried to run the java class it didn't know which java to take as it has two version of java available. the solution is available

as jcarlosgarciav told us. well you have set the classpath but did you set the path variable?

if you haven't then try this: goto the environment variable>edit the PATH variable if it is alredy set/create a new PATH variable if it isn't already there>append a variable value:C:\jdk1.5.0_04\bin;

at the end. thats it you are done.

another way you can easily solve the problem by running the class file by calling the java with absolute path like this:

C:\>C:\jdk1.5.0_04\bin\java myclass bla bla

or by

setting path at the command prompt each time you open one window

mr47a at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 9

Just paste ur most recent version of java in ur path before the oracle version path

D:\jdk1.5.0_09\bin;C:\oracle9i\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Common Files\Teleca Shared;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;D:\javaprog;.;

shibinpaula at 2007-7-13 11:44:05 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...