Netbeans how to set command line arguments in Java

前端 未结 10 1345
陌清茗
陌清茗 2020-11-27 16:36

I am trying to set command line arguments in a Netbeans 7.1 Java project on Windows 7 64 bit.

Netbeans is not passing the arguments I give it.

I go to

10条回答
  •  天命终不由人
    2020-11-27 17:05

    For a Maven project using NetBeans 8.x:

    1. Click Run >> Set Project Configuration >> Customise
    2. Select Actions
    3. Select Run file via main()
    4. Set name/value pair to include the arguments.
    5. Click OK

    An example name/value pair might resemble:

    javax.persistence.jdbc.password=PASSWORD
    

    Then run your project:

    1. Open and focus the Java class that includes main(...).
    2. Press F6 to run the program.

    The command line parameters should appear in the Run window.

    Note that to obtain the value form with the program, use System.getProperty().

    Additional actions for Test file, Run project, and other ways to run the application can have arguments defined. Repeat the steps above for the different actions to accomplish this task.

提交回复
热议问题