A Java project can have several entry points, each with its own inputs. On the Linux desktop, IntelliJ IDEA lets you save a named Java run configuration for one entry point so you can launch it with the same arguments again.

An Application configuration starts a class with a main method. The selected module supplies the compiled classes and dependencies that the Java runtime can load.

Java passes Program arguments to the main method as strings. A program that uses or prints those strings gives you a way to check which argument reached it.

Steps to create a Java run configuration in IntelliJ IDEA:

Start with a trusted Java project open in IntelliJ IDEA, with a configured JDK and an entry class that prints its arguments. IntelliJ IDEA shows its main menu under the Main Menu button in the window header. In the sample project at ~/IdeaProjects/Hello, the Hello module contains demo.Main, which prints its arguments in the Run tool window.

  1. Click the Main Menu button in the window header.
  2. Open the Run menu in the expanded header.
  3. Choose Edit Configurations… from the Run menu.
  4. Click Add (the plus sign) in Run/Debug Configurations.
  5. Select Application from Add New Configuration.
  6. Click the Name field.
  7. Replace the current Name with a name for your configuration, such as Greet locally.
  8. Open Modify options.
  9. Enable Use classpath of module under Java if it is unchecked.
  10. Press Esc to close Add Run Options.
  11. Open the classpath dropdown marked -cp beside the JDK field.
  12. Select the module that contains your entry class, Hello in the sample project.
  13. Click the Main class field.
  14. Click Got It if the This option will be hidden tip appears.

    IntelliJ IDEA can hide the classpath dropdown the next time you open the configuration if it uses the default module.

  15. Enter the full name of your entry class in Main class, including its package, such as demo.Main.
  16. Press Esc if a completion popup is open beneath Main class.
  17. Click the Program arguments field.
  18. Enter a non-sensitive argument your program expects, such as world, in Program arguments.

    The Run tool window shows the launch command, including its arguments.

  19. Click OK to save the named configuration.
  20. Click the green Run button next to the saved configuration in the toolbar.
  21. Confirm in your configuration's Run tab that the program printed your argument on its own output line, such as Received: world in the Greet locally tab.
Share this guide