The most intelligent Java IDE
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Beginning Java
 
RSS feed
 
New topic
Author

Java 1.4 under Java 1.6?

Jochen Rittmann
Greenhorn

Joined: Jun 20, 2009
Messages: 2

Hello,
can i run an J2EE Application which is written under Java 1.4 in Java 1.6. Only compile 1.6 and then run?
Is there a official documentation about this theme?
Thank you,
Jochen
Pushkar Choudhary
Ranch Hand

Joined: May 21, 2006
Messages: 353

Java does have good backward compatibility. Refer to this on the Sun Java website regarding compatibility.
Jesper Young
Java Cowboy
Bartender

Joined: Aug 16, 2005
Messages: 7862

Each version of the JDK comes with information about backward compatibility, Pushkar provided you already with a link for Java 6.

Backward compatibility has always been very important for Java. Normally you should not have any problems running old applications on a new version of Java. You do not even need to recompile the code - the old compiled classes should run fine. But you should test it first with your particular application - some programmers use unofficial APIs or other techniques that make their programs incompatible with newer versions of Java, it's impossible to guarantee 100% that everything will work.

This message was edited 1 time. Last update was at by Jesper Young


Java Beginners FAQ - JavaRanch SCJP FAQ
The Java Tutorial - Java SE 6.0 API documentation
Rob Prime
Bartender

Joined: Oct 27, 2005
Messages: 8837

There are two reasons a program may break when upgrading your JVM:

1) programmers have used undocumented classes, like those in package that start with sun, sunw or com.sun. These classes can change or even disappear even between minor JVM updates.

2) there was a bug in the API at the earlier version, and the programmer has created a workaround. That workaround now causes bugs in the code since it is no longer needed.


The first one is much more frequent though.

SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Messages: 486

And, if I recall correctly, there were some new reserved words between 1.4 and 1.6, such as enum. I'm not sure how much of a problem that will cause, but I believe it has been discussed on here before.

SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

Yes that is true however that is only a problem at compile-time:

Compile with 1.6: javac -source 1.4 Test.java --> Only a warning

Run with 1.6 java Test --> No error/exception

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Beginning Java
 
RSS feed
 
New topic
hibernate profiler