Reputation: 3114
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
Reputation: 2224
In NetBeans IDE 8.0 you can use a community contributed plugin named NbRunWithArgs. This plugin provides features like
You can read more details about this plugin on this blog post.
Upvotes: 0
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