Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Build in multiple java versions using Ant

Posted on 2008-10-20
1
Medium Priority
?
976 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 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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:
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

927 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