Saturday, March 22, 2014

Command line Arguments for Java Projects in NetBeans IDE

Topics Covered
  1. Exploring "Run with Arguments" module
  2. Providing command line arguments to single Java Files
NBRunWithArgs is a new NetBeans IDE module which is created by yours truly :)
It is available at the URL .  To install this plug-in we have to follow these steps.

  1. Ensure you are using the latest and greatest NetBeans IDE 8.0
  2. Download the latest realease 1.1.0 NBM file from the releases page of project site.  The exact link for the download of release 1.1.0 can also be used.
  3. Open the Plugin Manager in NetBeans IDE by using Tools > Plugins menu option
  4. Navigate to the Downloaded tab and using the Add Plugins... button locate the downloaded NBM file and install it, approve the certificate.
  5. NetBeans IDE will restart and then the plugin is ready for show
How to use the plugin:

Run Project with Arguments
1. The command will be available in the Run Menu or context menu of a Java project (right click menu)

Run a single file with Arguments
This is a feature which is not available by any other way in NetBeans IDE 8.0 yet.  Even if your project has many files having main method you can right click the file you want and use the Run with Arguments command to run the file with command line arguments


  1. This is rather interesting! What about running/debugging a web application with embedded jetty ?
    I develop all my modules within netbeans, and I can set maven goals for compilation, but when it comes to debugging and running, I always go back to the command line and execute :
    "java -jar webapp.war" for running, and
    "java -Xdebug -Xrunjdwp:transport=dt_socket,address=8800,server=y,suspend=y -jar webapp.war", then attaching netbeans debugger to the 8800 port for debugging, which is pretty tedious I must say, so how would you have it all done from within netbeans IDE?

  2. How convenient ! Thank you !

  3. Thank you! This worked for me!

  4. It worked, thanks for easing out a longstanding confusion..

  5. Thank you very much for the plug-in.
    It helped me solve some of my problems. My main goal though is to be able to debug a file with arguments in Netbeans (something similar to what Mr. Morena mentioned). Is there a way to do that with the plug-in?

    Thanks again.

  6. Worked great! Thank you very much! Although it seems like this plugin only works for Ant-based projects :(