java run version in linux

G

GSA

Hi all,

Hi,
I use Ubuntu Linux
Below is my java version detail. I had actually installed 1.6.x
version and reverted to 1.5.x version as this was my need.

user1@xxxx-desktop:/usr/bin$ java -version
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02)
Java HotSpot(TM) Server VM (build 1.5.0_19-b02, mixed mode)
user1@xxxx-desktop:/usr/bin$ javac -version
javac 1.6.0_22

Since the java and the javac version are different, I am not able to
run the program.
I get the following error;
java.lang.UnsupportedClassVersionError: Bad version number in .class
file
..
..
..
..
..
Please help me change the version of the java. I browsed the net but
in vain :-(

Thanks in advance
 
L

Luuk

Hi all,

Hi,
I use Ubuntu Linux
Below is my java version detail. I had actually installed 1.6.x
version and reverted to 1.5.x version as this was my need.

user1@xxxx-desktop:/usr/bin$ java -version
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02)
Java HotSpot(TM) Server VM (build 1.5.0_19-b02, mixed mode)
user1@xxxx-desktop:/usr/bin$ javac -version
javac 1.6.0_22

Since the java and the javac version are different, I am not able to
run the program.
I get the following error;
java.lang.UnsupportedClassVersionError: Bad version number in .class
file
.
.
.
.
.
Please help me change the version of the java. I browsed the net but
in vain :-(

Thanks in advance

I'm not working with Ubuntu, but you can try to use the whereis command
to find out where java and javac are located

On my opensuse system i find a symbolic link in /usr/bin, which points
to another symbolic link in /etc/alternatives, which finally point to
the location of my jre

I think you did not uninstall 1.6 ? So, probably its in your $PATH
somewhere....

opensuse:/var/log/apache2 # whereis java
java: /usr/bin/java ......
opensuse:/var/log/apache2 # ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-02-14 13:30 /usr/bin/java ->
/etc/alternatives/java
opensuse:/var/log/apache2 # ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 37 2010-10-23 18:01 /etc/alternatives/java ->
/usr/lib64/jvm/jre-1.6.0-sun/bin/java
opensuse:/var/log/apache2 #
 
G

GSA

I'm not working with Ubuntu, but you can try to use the whereis command
to find out where java and javac are located

On my opensuse system i find a symbolic link in /usr/bin, which points
to another symbolic link in /etc/alternatives, which finally point to
the location of my jre

I think you did not uninstall 1.6 ? So, probably its in your $PATH
somewhere....

opensuse:/var/log/apache2 # whereis java
java: /usr/bin/java ......
opensuse:/var/log/apache2 # ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-02-14 13:30 /usr/bin/java ->
/etc/alternatives/java
opensuse:/var/log/apache2 # ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 37 2010-10-23 18:01 /etc/alternatives/java ->
/usr/lib64/jvm/jre-1.6.0-sun/bin/java
opensuse:/var/log/apache2 #

i uninstalled it. But not sure where this path needs to be altered
 
R

Roedy Green

Please help me change the version of the java. I browsed the net but
in vain :-(

That would not help. JavaC 1.6 generates code that uses methods that
Java 1.5 does not have.

You must either:

1. upgrade your Java.exe to 1.6
2. tell JavaC 1.6 to generate code for level 1.5 with the -source and
-target options.

You might find the tools Jarlook and Jarcheck useful for examining
Jars to see which versions of Java each class demands.
http://mindprod.com/products1.html

Unless you are working at a giant corporation there is likely no
reason to stick with Java 1.5.
 
L

Lew

GSA said:
I use Ubuntu Linux
Below is my java [sic] version detail. I had actually installed 1.6.x
version and reverted to 1.5.x version as this was my need.

user1@xxxx-desktop:/usr/bin$ java -version
java version "1.5.0_19"

This is an out-of-date version of Java 5, which at the end of its service life
(EOSL) was frozen at 1.5.0_22. There is at least one critical security patch
involved. If you must use an obsolete version, at least use the patched one.
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02)
Java HotSpot(TM) Server VM (build 1.5.0_19-b02, mixed mode)
user1@xxxx-desktop:/usr/bin$ javac -version
javac 1.6.0_22

Since the java and the javac version are different, I am not able to
run the program.
I get the following error;
java.lang.UnsupportedClassVersionError: Bad version number in .class
file
.
Please help me change the version of the java. I browsed the net but
in vain :-(

I use Ubuntu, but the principle is the same in Windows. Your PATH environment
variable (envar) points to the wrong version(s).

You could get rid of that obsolete Java 5 and just set your Java 6 compiler to
generate 5-compatible class files.

What is the expansion of your PATH envar?
 
L

Lew

Roedy said:
You must either:

1. upgrade your Java.exe [sic] to 1.6

That won't work as the OP stated:
Therefore no "java.exe".
2. tell JavaC [sic] 1.6 to generate code for level 1.5 with the -source and
-target options.

You might find the tools Jarlook and Jarcheck useful for examining
Jars to see which versions of Java each class demands.
http://mindprod.com/products1.html

Unless you are working at a giant corporation there is likely no
reason to stick with Java 1.5.

Let alone an unpatched version of Java 5.
 
A

Arne Vajhøj

That would not help. JavaC 1.6 generates code that uses methods that
Java 1.5 does not have.

Only if the programmer tell it to.

It could potentially generate code invalid in older
JVM's and it will certainly will generate code with a
higher class file version preventing it from running
in older JVM's.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top