4

I am just wondering is there a way in NetBeans to start Java application with console arguments (I mean the default ones input for main method)? I mean the effect like when you run your app with Command Prompt manually:

>MyTestApp arg0 arg1 argN

I couldn't find the IDE feature so I need your advice. Is there a way to run apps with NetBeans in that way?

P.S. NetBeans 6.5.1

3 Answers 3

8

Right click on your project's name and select "Properties" from the menu. One of the tabs in that window lets you set command-line arguments. I don't recall the exact one off the top of my head.

3
  • 1
    In the new versions of Netbeans this option in properties is no longer available. Commented Dec 6, 2014 at 9:46
  • I have some projects that have the run property, and others that do not. I'm currently running NB 8.2. Commented Aug 20, 2021 at 13:16
  • @RichardJessop If you have a question, please click on the "Ask a question" button at the top right of any page on this site. Commented Aug 20, 2021 at 13:48
2

After you build the project Netbeans will show you the build results in the output pane. simply copy the last line that indicates the location of the main jar file executable, for example:

java -jar /home/abusada/NetBeansProjects/userInput/dist/userInput.jar

start your terminal on Linux or console on Windows and paste the above.

Hit enter to run your file.

1

You can go to Run Configurations... and set your VM Settings there. It should be passed on to the console when it runs.

1
  • Thanks for further steps tips :)
    – user592704
    Commented Dec 20, 2012 at 1:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.