File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes 1.4 Compiler - 1.3 JRE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "1.4 Compiler - 1.3 JRE" Watch "1.4 Compiler - 1.3 JRE" New topic

1.4 Compiler - 1.3 JRE

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

If I write a program and compile it use the 1.4.1 compiler but I know that all the API's I used are the same as 1.3.x, is it safe to say that the application will run correctly on a 1.3.x JRE?

GenRocket - Experts at Building Test Data
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I would venture to say probably not. Even though the API spec hasn't changed, perhaps some minor change in the way the two versions create the byte codes in the class file could cause it to not run correctly, if at all. However, if you use a 1.3.x compiler, it should run on both 1.3.x and 1.4.x JREs.
Disclaimer: This is my (only slightly) educated guess. Hopefully someone else will chip in if I am too far off base.

Java API Documentation
The Java Tutorial
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
You can use a 1.4 compiler to create .class files which execute on 1.3 with the -target option:
javac -target1.3
If your code uses any features that are only available in 1.4, you'll get an appropriate error message when you compile.

"I'm not back." - Bill Harding, Twister
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

What if you don't use the -target option. Any documentation on the difference in bytecode from one version to the other without reading the VM specs for each version and figureing it out? Did anyone just say "Here is the difference"?
I agree. Here's the link:
subject: 1.4 Compiler - 1.3 JRE
It's not a secret anymore!