You need to modify code of a Java NetBeans project but you neither have or want to install that IDE in order to re-compile it.
Use Apache Ant to compile your Java code.
-
Create a folder (e.g.
lib) in your project, at the same level ofnbproject, and save all dependencies (jars) there.~$ cd /path/to/your/app && mkdir lib && cp /path/to/jars lib/ -
Save there also
org-netbeans-modules-java-j2seproject-copylibstask.jar. This jar is required to execute NetBeansbuild.xml.-
Where do I find this jar?
Its path can be extracted from
build.propertiesin foldernbproject -
What if not available there?
If you had an old version of NetBeans installed, check
.netbeans/<version>/build.properties
-
-
Create a wrapper (e.g.
build-ext.xml) for NetBeansbuild.xml, at the same level ofnbproject, to overwrite properties from the environment variables.For example
${platforms.nameofyourplatform.home}was defined either innbproject/build-impl.xmlornbproject/build.propertiesasplatforms.java -
Fill in the wrapper with something similar to the following
<?xml version="1.0"?>
<project name="BUILD-EXT" default="build-ext" basedir=".">
<import file="build.xml"/>
<property environment="env"/>
<property name="platforms.java" value="${env.JAVA_HOME}" />
<target name="build-ext" depends="default"/>
</project>- Run
antby executing~$ ant -Dlibs.CopyLibs.classpath=lib/org-netbeans-modules-java-j2seproject-copylibstask.jar -f build-ext.xml-
Got error
copylibs doesn't support the "excludeFromCopy" attribute?At line XX (specified in the error) of
build-impl.xmlremove settingexcludeFromCopy, save and runantcommand again
-