score:57

Accepted answer

Instead of just hitting the "Run" icon, select the dropdown box next to it, and choose "Run Configurations". Find your application (or create a Run Configuration for it) and put the command line arguments in the "Arguments" tab. See the docs for more information. It should look like this:

enter image description here

score:0

Run-> Run Configurations->Arguments->Enter your arguments separated by space->Apply->Run Ensure that the right project name and it's main method are selected under "the Main" tab under run configurations

score:0

this work for me, in public static void main method.

public static void main(String argv[]) throws Exception {
    int port_com = 2;
    boolean debugMode = true;
    int socket = 6789;
    HasarMain hasarMain = new HasarMain();

    // Check if a command line argument exists
    if(argv.length != 3){
        System.out.println("Missing, Port - socket - debugMode!");
        System.exit(0);
    }

    port_com = Integer.parseInt(argv[0]);
    socket = Integer.parseInt(argv[1]);
    debugMode = Boolean.parseBoolean(argv[2]);

Run-> Run Configurations->Arguments->Enter your arguments separated by tab->

${string_prompt:argv:"2" "6789" "true"}

Eclipse

score:3

From "Run" go to debug/run configurations. Click the tab called "Arguments". You can give the program arguments there.

score:3

Run configurations > Arguments tab. Just put "127.0.0.1" 9876 in the program arguments.

score:7

Want to add something like, how to add multiple parameters.

  1. Right-click on your project.
  2. Debug > Debug Configurations
  3. Go to Arguments tab.
  4. Enter in your Program Arguments, each separated by a new line. (e.g 3 arguments in attached image)
  5. Click Apply or Debug

enter image description here

Hope it helps.

score:11

  1. Right-click on your project.
  2. Go to Debug As > Debug Configurations or Run As > Run Configurations.
  3. Click the tab that says Arguments.
  4. Enter in your Program Arguments
  5. Click Apply or Debug

enter image description here

score:16

See the run configurations. You can specify arguments. You can even prompt the user for arguments, along with defaults:

${string_prompt:host:127.0.0.1} ${string_prompt:port:9876}

The first prompt is host, with default value 127.0.0.1 filled in. Second pop-up has the prmpt port, with 9876 filled in


Related Query

More Query from same tag