Solved

Build in multiple java versions using Ant

Posted on 2008-10-20
1
952 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

820 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