How to pass argument to main class in netbeans?
UPDATED: 17 April 2012
Tags:
Netbeans at glance
Step 1: Right click on project and click on "Set as Main Project". Now Right click on project and go to "Properties" > "Run" option as shown in below image.
Step 2 : You can see that there is browse... option for "Main Class" click on it. And select the class you wanna pass the argument. The class you select as a Main Class will always run as first class on starting of the project.
Step 3: Pass the argument as show in below image. If you wanna pass multiple argument separate it by space.
Note : If you run the class by right clicking on file. It won't accept argument and give you ArrayoutofBound Exception. To use that argument you must run whole project. Use PLAY button on top tool bar or right click on project and click RUN.
- - int : 10
- - String single word : Hello
- - String more then one word : 'Hello World' (use single quote)
Tags:
Netbeans at glance
0 comments :