Solved

Build in multiple java versions using Ant

Posted on 2008-10-20
1
940 Views
Last Modified: 2013-12-14
Hi,

I have a project written in NetBeans 6.1 that I need to be able to compile on demand using any JDK version from 1.4.2, on a machine that does not have NetBeans installed (but does have Ant of course). The app compiles under 1.4.2 and up using the Ant xml files generated by NetBeans. At the moment, the options are 1.4.2/1.5/1.6 as they are the JDKs that are installed on the machine. The application uses Swing so has a couple of dependant jars.

Modifying the xml build files is not an option. Specifying a properties file from the Ant command-line is fine, and I have had to do this anyway (as well as copying the swing and NetBeans copylibs jars to the machine). The file is autogenerated and is created automatically before calling Ant.

Are there properties I can add to my properties file to specify which version of the SDK to compile with? Any other suggestions?

Using Windows.
Current properties file, used with ant -v -propertyfile temp.properties jar:
 

libs.swing-app-framework.classpath=appframework-1.0.3.jar;swing-worker-1.1.jar

libs.CopyLibs.classpath=org-netbeans-modules-java-j2seproject-copylibstask.jar

Open in new window

0
Comment
Question by:scuzzie
1 Comment
 
LVL 2

Accepted Solution

by:
szigeti earned 500 total points
ID: 22952263
Hi Scuzzie,

Let's say your build machine is running JDK 1.6, and Ant 1.7. You want to build classes you can distribute to clients running 1.4.2, 1.5, and 1.6 JREs respectively.:

Please note:
1. You cannot use any 1.6 specific functionality in your code, as that is not availabe in 1.5 and 1.4.2 clients.
2. You need Ant 1.7 to do this.

For 1.4.2 set these properties in your file:
ant.build.javac.source=1.4
ant.build.javac.target=1.4

For 1.5 set these properties in your file:
ant.build.javac.source=1.5
ant.build.javac.target=1.5

For 1.6 set these properties in your file:
ant.build.javac.source=1.6
ant.build.javac.target=1.6
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 77
Hibernate Not Rolling Back When something fails in a stored procedure 2 51
Java JRE greater than 1.6 5 50
javap not working 8 36
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now