TaT PassRuntimeArgs

Tips & Tricks | Passing Runtime Arguments using NetBeans

Doc Contributor; Varun Nischal

[[{TableOfContentsTitle=TableOfContents} | {TableOfContents title='Table of Contents'}]]

Brief Overview

Note -
Before I begin, I would like to mention, that recently, Sun distributed 100 NetBeans IDE Tips & Tricks Mini-Book at NetBeans Day! Adam Myatt, had announced it on NetBeans Dzone and listed title’s of all the Tips & Tricks! So, I was not sure whether Tip 31, is similar to the one I’m mentioning or not! When there were no IDE’s, all of us, would depend on CLI (Command Line Interface), to run and test our programs! You might have set the CLASSPATH, to run your Java programs from the working directory! Then, we use to pass runtime arguments to programs, to do the necessary work.


Now, when we have IDE’s, I would rather like to master the IDE and do everything possible to create efficient applications, than go on CLI and waste my time.

However, sometimes I feel that one should be accustomed to work on the CLI as well, as these are the basics, until and unless your basics are strong, you can’t go into the depth of a particular domain!

Problem Description

So, I thought of making use of runtime arguments through the IDE, is it possible! Well, any new NetBeans User would be surprised to know, that its possible.


NetBeans 6.0, 6.1 provide a way, but this no longer serves the purpose of sending the arguments dynamically, i.e. you have to set pre-defined arguments before running the program…

Have a look at the screenshots;


Fig 1. Right-click the Project Node, select the appropriate menu-item to goto Project Configuration Window.


Fig 2. Click on Run, as you can see, then see to its right there’s a label ‘Arguments’, select the text-box next to it.


Fig 3. Now, enter arguments, I tried using “Hello” and “World”, space has to be there for separating arguments as you would do in a CLI.


Fig 4. Edit Main.java, to see whether your application prints the arguments in Output Window.


Fig 5. Well, it does! See the Output Window.

Similarly, you can do it for NetBeans 6.1 Beta, Release Candidate 1, 2 and NetBeans 6.1 FCS!


Anyways, try this out and do let me know, whether its helpful OR not!

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo