Run NetBeans project just with ant

OscarRyz picture OscarRyz · May 26, 2009 · Viewed 20.5k times · Source

I have a sample code that was built with Netbeans.

It has a build.xml file so I downloaded ant and try to run it.

I've got this error message:

...... nbproject\build-impl.xml:76: Platform is not correctly set up

For what I can see, this is fixed by "simply" downloading Netbeans and running the sample from there, but... I don't want to install it to run a 10 files sample.

Is there a workaround to run Netbeans projects with Java? What's the correct .properties file I have to modify?

Answer

Mads Hansen picture Mads Hansen · May 27, 2009

It is possible to run the NetBeans generated projects straight from Java/ANT, but you may need to manually set some of the properties and/or add paths to jar files.

Unfortunately, NetBeans tends to include taskdef's using their own JAR files and reference properties that are defined only in the /nbproject/private/private.properties files, which usually get set when you first open the NetBeans project or modified as you edit the project in the IDE.

If you inspect the build-impl.xml you should be able to find the property and derive what value needs to be set(OS platform), then either:

  • create/set the property in the /nbproject/private.properties
  • add that property definition in the parent build.xml
  • pass in the commandline when invoking your ant target using -DPlatform=Foo

Personally, I like the structure of the NetBeans generated ANT files and targets, but hate how much custom/proprietary stuff they jam in that makes it hard to run without NetBeans.

For example:

ant -Dplatforms.JDK_1.7.home=/opt/jdk