Solved

Build in multiple java versions using Ant

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

746 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

7 Experts available now in Live!

Get 1:1 Help Now