Skip to main content

Command line parameters

4 replies [Last post]
mcvillarp
Offline
Joined: 2008-01-28
Points: 0

Hi,

I new in Java and NetBeans.

I would like to know, ¿how do I send "command line" parameters to main method in NetBeans IDE 6?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mbien
Offline
Joined: 2007-04-29
Points: 0

Hi,

follow these steps:
1. make sure your project is marked as main project (right click on your project | mark as main project)
2. select "customize..." in the combo box in the toolbar on top
3. finally put your program arguments into the Arguments field and press OK to safe your new (you may also create a new configuration if you like)

hope that helps

mcvillarp
Offline
Joined: 2008-01-28
Points: 0

Thanks,

Just a comment, because I'm testing I have a project with 2 packages and many sources codes.

After I followed your steps, I was making a mistake ... I was running de File no the Project.

Now, I'm running the project, with the name of my code in the Main Class and it is working.

Thanks again.

hacktor
Offline
Joined: 2008-03-05
Points: 0

OK, I tried your advice, however it is not working.

I am attempting to pass an argument to main via the method you explained, but when I try to access args[0], I get an an ArrayIndexOutOfBoundsException

Any advice?

mbien
Offline
Joined: 2007-04-29
Points: 0

please try it again it will work. Just run the project with the green arrow on top of the IDE and not via context menu of your class containing the main method.

edit: i would upload an image but this forum category does not support file uploads :/