How do I set the ant bootclasspath in conjunction with -source 1.5 -target 1.5?
How can this not be a hardcoded path to the 1.5 JDK? Can I set an environment variable to bootclasspath similar to how JAVA_HOME can be used from ant?
Ideally I would like to do something like set an environment variable or pass an argument to ant.
It's worth noticing that variable
JAVA5_BOOTCLASSES
should contain all needed libraries not just rt.jar. In my case it was also jce.jar So it's good to set this variable using this simple snippet when in *nix environment:Here's an illustration of how you might fetch the Java 5 boot classes location from an environment variable, then use it.
First, set the environment variable - say
JAVA5_BOOTCLASSES
. Theproperty
task gives you access to the environment, then thebootclasspath
argument of thejavac
task passes the setting to the compiler.Note that if the environment variable is not set, Ant will ignore it and proceed without - so the compiler will fall back to the default boot classpath.
Another option, if appropriate, is to switch off the warnings, and not bother with the bootclasspath. Something like
But that's likely to expose you to some subtle bugs.