Solved

Build in multiple java versions using Ant

Posted on 2008-10-20
1
956 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

739 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