How to pass console arguments to application in eclipse?

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


  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


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

Tags:

Java

Eclipse