user472221
user472221

Reputation: 3114

command line arguments.

I am beginner and I want to pass a string as a command line argument in netbeans .how can i do this? thanks

Upvotes: 0

Views: 285

Answers (3)

Tushar Joshi
Tushar Joshi

Reputation: 2224

In NetBeans IDE 8.0 you can use a community contributed plugin named NbRunWithArgs. This plugin provides features like

  1. Run project with Arguments (Context menu and Run menu option)
  2. Run File with Arguments context menu for Java files having main method

You can read more details about this plugin on this blog post.

Upvotes: 0

Donal Fellows
Donal Fellows

Reputation: 137567

In a standard Java program that can take command line arguments, there will be a class that acts as the entry point of the whole program. That class will have a static method in it like this:

public class FooBar {
    // ...
    public static void main(String[] arguments) {
        // ...
    }
    // ...
}

The arguments are in the array that is the parameter to that method, which must have that signature and be both public and static. If you're using a hosting engine or framework, the entry point is often taken care of for you; you should consult its documentation to see how to get command line arguments (if that is possible at all, or even reasonable).

Command line arguments are always strings. If you want to interpret them as something else, you've got to convert them manually.

Upvotes: 1

chris13work
chris13work

Reputation: 89

A Tut for it: http://wiki.netbeans.org/TaT_PassRuntimeArgs

Upvotes: 0

Related Questions