tomcat with java 1.5 -1.6

F

finecur

Hi,
I have a question with tomcat/eclipse/java versions.

1. On my server, run tomcat with java 1.5.0
2. On my development machine, running eclipse with java 1.5.0.

Every thing worked fine. I recently got a new computer and installed
eclipse and java 1.6.0. I found that the jar file I compiled on the
new computer no longer works on the server. Does anyone know why?

Thanks,

ff
 
S

shakah

Hi,
I have a question with tomcat/eclipse/java versions.

1. On my server, run tomcat with java 1.5.0
2. On my development machine, running eclipse with java 1.5.0.

Every thing worked fine. I recently got a new computer and installed
eclipse and java 1.6.0. I found that the jar file I compiled on the
new computer no longer works on the server. Does anyone know why?

Thanks,

ff

Does it work if you build (on your 1.6 box) using javac's "-target
1.5" option?
 
R

Roedy Green

Every thing worked fine. I recently got a new computer and installed
eclipse and java 1.6.0. I found that the jar file I compiled on the
new computer no longer works on the server. Does anyone know why?

check it out with JarCheck. I made have classes marked as JDK 1.6+
only.

You need to compile on that new machine with -target 1.6

Or you need to upgrade everyone or downgrade the new machine.

see http://mindprod.com/jgloss/products1.html#JARCHECK
 
R

Roedy Green

Because Java 6 has some new functionalities that 5 didn't have, like
Enum class I think.

1.4 added regexes, assertions and nio.

1.5 added StringBuilder, java.util.concurrent, generics, enumerations
and annotations.

1.6 added System tray, subpixel antialiasing, Document-modal,
Application-modal, Toolkit-modal, Applet splash screens, table
sorting, true double buffering, digitally signed XML files, JAWS
support for *.ico and *.png, JavaCompiler, JDBC 4.0, smart card API,
Console.readPassword, improved drag & drop
 
N

Nigel Wade

finecur said:
Hi,
I have a question with tomcat/eclipse/java versions.

1. On my server, run tomcat with java 1.5.0
2. On my development machine, running eclipse with java 1.5.0.

Every thing worked fine. I recently got a new computer and installed
eclipse and java 1.6.0. I found that the jar file I compiled on the
new computer no longer works on the server. Does anyone know why?

Thanks,

ff

Java is backwards compatible, not forwards compatible. That is, a 1.6 JVM will
run code compiled by a 1.5 JDK, but not vice versa.

Your new computer has a 1.6 JDK and generates bytecode which requires a 1.6 JVM
to execute. You can upgrade your server so that Tomcat runs a 1.6 JVM. You
might also install a 1.5 JDK on your desktop and use that platform to build the
jar (I don't know how to setup Eclipse to use alternative platforms, but I
presume it can be done).

Finally, you could try using the "-target 1.5 -source 1.5" options of the javac
compiler to tell it to generate 1.5 compatible bytecode. You might get away
with it. Note, though, that to do this properly requires you to have at least a
1.5 runtime environment in order to set the -booclasspath and -extdirs options
correctly. So you might as well use a 1.5 JDK and the 1.5 compiler.
 
A

Arne Vajhøj

finecur said:
I have a question with tomcat/eclipse/java versions.

1. On my server, run tomcat with java 1.5.0
2. On my development machine, running eclipse with java 1.5.0.

Every thing worked fine. I recently got a new computer and installed
eclipse and java 1.6.0. I found that the jar file I compiled on the
new computer no longer works on the server. Does anyone know why?

No.

"no longer works" is not sufficient description of the error
to say what the cause is.

Try give us the exact error you are getting on what code.

Arne
 
D

Donkey Hot

No.

"no longer works" is not sufficient description of the error
to say what the cause is.

Try give us the exact error you are getting on what code.

Arne

My favorite IDE has an option in the properties of the "project":
Source/binary format.

All versions from JDK 1.2 to JDK 6.

Just select JDK 5, if you have such an option in your Eclipse.
 
A

Arne Vajhøj

Donkey said:
My favorite IDE has an option in the properties of the "project":
Source/binary format.

All versions from JDK 1.2 to JDK 6.

Just select JDK 5, if you have such an option in your Eclipse.

And that is supposed to help on the error "I found that the jar
file I compiled on the new computer no longer works on the server" ??

Arne
 
D

Donkey Hot

And that is supposed to help on the error "I found that the jar
file I compiled on the new computer no longer works on the server" ??

Arne

Apparently yes, if the reason for incompatibity is the Java 6 compiler and
Java 5 runtime on server.
 
A

Arne Vajhøj

Donkey said:
Apparently yes, if the reason for incompatibity is the Java 6 compiler and
Java 5 runtime on server.

Yuck.

You are right. The most obvious error based on the description
is of course:

java.lang.UnsupportedClassVersionError: Bad version number in .class file

I did not think of that.

Yes - that suggestion is a very good suggestion.

Arne
 
T

Tarin Gamberini

(I don't know how to setup Eclipse to use alternative platforms, but I
presume it can be done).
I develop by Eclipse 3.3.2 useing a jdk 1.6, so I've setted in the
Windows \ Preferences \ Java \ Installed JRE the jdk 1.6.

A jre (1.)5.0 run on our server, so I've setted a jdk compiler
compliance level to (1.)5.0 in Windows \ Preferences \ Java \ Compiler.

Tarin
 
R

Roedy Green

Apparently yes, if the reason for incompatibity is the Java 6 compiler and
Java 5 runtime on server.

I have found a general rule that has worked well for me. When I find
something wrong, I fix that, then retest for problems. Often various
problems mysteriously disappear. The causal chains can be so subtle
you could spend weeks figuring out why that error could cause all that
strange behaviour. There is no need to. Just fix it and have a new
look at what problems remain. This applies on many levels, even
something as simple as mysterious compiler error messages.
 

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,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top