aspose file tools*
The moose likes Java in General and the fly likes Compiling Java 6 code to 1.3-compliant bytecode? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Compiling Java 6 code to 1.3-compliant bytecode?" Watch "Compiling Java 6 code to 1.3-compliant bytecode?" New topic
Author

Compiling Java 6 code to 1.3-compliant bytecode?

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
I'm developing a library that contains some functionality that is only available in Java 6.0. I want anyone using the package to be able to deploy the jar file to older JDKs (1.3). I already have code that detects the JRE version and pops a warning if it's not 6.0, but I want to be able to compile to 1.3-compliant bytecode, so the developer can at least use the rest of the non-6.0 functionality. Is there a way to do this in an Ant <javac> task?

I would imagine I'm looking to compile using JDK6.0, but to 1.3-compliant bytecode. Is this possible?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
Yes, that's possible. Check out the "source" and "target" attributes of the javac task. They provide the same functionality as the -source and -target javac command line switches.


Ping & DNS - my free Android networking tools app
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Thanks Ulf, this worked perfectly!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compiling Java 6 code to 1.3-compliant bytecode?