• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

UnsupportedClassVersionError

I have installed jdk1.5.0. Why am I getting an UnsupportedClassVersionError when I try to run a simple java app? The code is:

import java.io.*;

public class zxc {

  public static void main(String[] args) {

     System.out.println("No Answer!");
  }
}

Any thoughts?
ipaman
0
ipaman
Asked:
ipaman
  • 5
  • 3
  • 3
1 Solution
 
CEHJCommented:
Make sure you're running against 1.5 JRE and not lower
0
 
ipamanAuthor Commented:
I have the jdk1.5 and the jre1.5 installed.
JAVA_HOME is set to jdk1.5.0
CLASSPATH has jdk1.5.0\*

Do I need to have the jre1.5.0 somewhere in the classpath?

ipaman
0
 
CEHJCommented:
You need to have java.exe (1.5) on your PATH

Add this line

System.out.println(System.getProperty("java.runtime.version"));

and then recompile with

javac -source 1.5 -target 1.4 zxc.java

and it'll tell you what runtime you're using
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
kiranhkCommented:
no you dont need to have jre1.5. it comes with JDK1.5
do java -version and see if u r using the JDK 1.5 or not.
0
 
CEHJCommented:
>>You need to have java.exe (1.5) on your PATH

Easiest to add

%JAVA_HOME%\bin

to your PATH. Make sure no other version there if you want clean separation
0
 
CEHJCommented:
>>no you dont need to have jre1.5. it comes with JDK1.5

What i'm getting at is that java.exe should be 1.5. You may have a < 1.5 JRE in the PATH
0
 
ipamanAuthor Commented:
CEHJ,
Running <javac -source 1.5 -target 1.4 zxc.java> didn't tell me much except that I had a problem. Maybe it is just my environment, who knows.

kiranhk,
I found out that I was running 1.3.1 which was added to my path from my Oracle 9.2.x install. I knew Oracle used this version of Java but didn't realize it tried to make everyone use that version.
The solution was to put jdk1.5.0\bin and jdk1.5.0\lib before any Oracle\jdk stuff in my path. When I tried to execute it found the version of java that Oracle was using.

Thanks,
ipaman
0
 
kiranhkCommented:
Good then.
I would suggest having a bat file which will set the environment for the particular requirement of the application so that u wont run into problems like these again when working with multiple applications requiring multiple JRE/JDK. This way u can have control over which JRE ur application need rather than changing the System variable everytime.

Thats how i manage my development.

Thanks
0
 
ipamanAuthor Commented:
kiranhk,

Can you supply an example bat file?
Thanks,
ipaman
0
 
kiranhkCommented:
save this something like setEnv.bat or whatever name u want


set path=D:\j2sdk1.4.2_05\bin;%path%  (here according to your application need have the %PATH% changed)
set classpath=D:\DryLoop-LSMSAdptrs\testcode\jars\lm.jar;%classpath%
0
 
CEHJCommented:
>>Running <javac -source 1.5 -target 1.4 zxc.java> didn't tell me much except that I had a problem

Well it tells you what version you're running, which *is* the problem

>>The solution was to put jdk1.5.0\bin and jdk1.5.0\lib before any Oracle\jdk stuff in my path

I told you that earlier:

>>
Easiest to add

%JAVA_HOME%\bin

to your PATH. Make sure no other version there if you want clean separation
>>
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now