Java applications can take inputs such as a name or a file path at startup. In Eclipse on the Linux desktop, a run configuration saves which Java class to start and which arguments to pass each time it runs.

A Java Application configuration ties the class that contains main to its project. Eclipse uses the project's classpath to find the classes and libraries the application needs.

The Program arguments field supplies values to String[] args in main. The separate VM arguments field controls how the Java virtual machine starts.

Start with your Eclipse workspace open and the Java file that contains main selected in Project Explorer and open in the editor. The Console view is open in the workbench, with its tab visible. Use a program whose output lets you tell whether it received your argument. The screenshots use ~/eclipse-workspace, the hello project, and Greeting.java, which prints a greeting using its first argument.

If Eclipse shows the Install Java 27 Support notice, you can choose whether to install support or defer it. Start at step 1 once the Java editor is visible.

Steps to create a run configuration in Eclipse:

  1. Click Run in the Eclipse menu bar.
  2. Choose Run Configurations… from the Run menu.
  3. Select the Java Application category in the list on the left.

    If the dialog opens with a saved launch selected, the category is the parent row above its launch names.

  4. Click New Configuration, the leftmost toolbar button above the configuration types.
  5. Open the Arguments tab of the new configuration.

    Eclipse fills in Project and Main class from the Java file you selected. The pictured configuration is named Greeting and launches example.Greeting from hello.

  6. Click the Program arguments field.
  7. Enter your program argument in Program arguments, such as Sam.
  8. Click Apply to save the argument in the configuration.
  9. Click Run to launch the saved configuration.
  10. Click the Console tab.
  11. Confirm in Console that the named Java Application launch shows the output you expect for your argument.

    For the Greeting launch, the output is Hello, Sam! because the argument is Sam.

Share this guide