10

I have a NetBeans project I would like to compile from the command line. There are many other questions on StackOverflow about how to do so, but they explain how to compile the project using commands like javac src/*.java.

I haven't changed my NetBeans project's build settings. By default, how can I compile my project from the command line using Ant? Once I've built my project, where is the compiled file located, and what format is it in (i.e., .class files, one .jar file, etc.)?

(I understand that asking how to use Ant to compile my project in general is too broad of a question. That's why I'm specifically asking about how to compile using NetBean's default configuration for a project.)

I'm using NetBeans 8.0.2.

2
  • It looks like I can run ant jar to run Ant and build my project. But once I've run it, I can't find the compiled program. I'm expecting to find it in the dist in my project's root directory, but it's not there... Commented May 2, 2015 at 21:19
  • I was able to fix the problem with my .jar file not appearing in dist/ by copying my project's source, deleting the NetBeans project, and recreating it. See stackoverflow.com/questions/5514672/… Commented May 3, 2015 at 1:33

2 Answers 2

8

ant compile Compiles the project (.class files are placed in the build/classes folder)

ant jar Compiles the project (see above) and builds a JAR ( located in dist/ )

If that doesn't work for you, check ant's output for errors. (Is the JAVA_HOME Variable set properly?)

Sign up to request clarification or add additional context in comments.

Comments

3

I'm totally agnostic IDE developer. After several frustrating years trying to emerge "netbeans ant config" to something usable from command line I became to create a wrapper for netbeans ant.

https://github.com/albfan/ant-netbeans

By now you can:

  • detect defined targets with standard

$ ant tabtab

  • Rely on project will honor JDK_HOME

and most important

  • Expect all ant target to complete smoothly, passing test and whatever stuff implied.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.