IntelliJ IDEA 2024.3 Help

Run applications

You can run applications right from IntelliJ IDEA if you have an SDK set up for your project/module.

Quick way

Run from the editor

If you are not going to pass any parameters to your program, and your program does not require any specific actions to be performed before start, you can run it right from the editor.

  • Click in the gutter near the class declaration and select Run.

    Run using the gutter icon

Run the current file

You can run single files using a dedicated option on the toolbar. The run and debug buttons are active and allow you to instantly run the currently opened file.

  1. In the editor, open the file that you want to run.

  2. Click Run next to the Current File option on the toolbar.

    Running a single file from the toolbar

You can access the other run modes by expanding the list. From the widget that opens, you can debug the code, run it with coverage, profile it, or open the run configuration to specify more options.

More options for running current file

Customizable way

  1. Click in the gutter near the class declaration and select Modify Run Configuration.

    Modify run configuration
  2. Modify the run/debug configuration as needed. For example, if you need to run your program with arguments, add the arguments to the Program arguments field.

    To access additional parameters, click Modify options and select the required option from the menu.

    run-customizable-2.png
  3. Click OK to save the run configuration for later, or Run to save and run it right-away.

When the application starts, you can view its output and interact with it in the Run tool window. Every run/debug configuration creates a separate tab when you run it.

A tab in the Run tool window

For more information about tool windows and how to manage them, see the Tool windows topic.

Re-run applications

  • On the toolbar of the Run tool window, click the Rerun button or press Shift+F10.

    Re-run button

Run multiple tasks

  • To run or debug multiple tasks simultaneously, open the run widget menu in the toolbar and select the corresponding run/debug configurations while holding down the Ctrl key

    %alt

For launching multiple tasks using a single run/debug configuration, refer to Run compound tasks.

Stop and pause applications

When you stop a program, its process is interrupted and exits immediately. When you pause a program, it continues running in the background, but its output is suspended.

Stop a program

  • In the Run tool window, click the Stop button on the toolbar. Alternatively, press Ctrl+F2 and select the process to stop.

    This performs a forceful termination of the program, meaning that the usual cleanup mechanisms at the operating system, virtual machine, and application levels may be bypassed, possibly preventing the execution of shutdown hooks, proper resource releasing, logging, and so on.

Terminate a program gracefully

  • In the Run tool window, click the Exit button on the toolbar.

    Unlike forceful termination, this terminates the program in a graceful way, the same as when it closes normally.

Pause the program output

  • Right-click in the Run tool window and select Pause Output from the context menu. Use the same toggle to resume the program.

    Pause output

Investigate errors

If there are errors in your program, here is how you can address them.

  • If an exception is thrown:

    • If the meaning of the exception is unclear, you can navigate to the exception class right from the stack trace and read the documentation for the exception to learn what it means.

    • Attach the debugger and examine the program state that led to the failure. See Tutorial: Debug your first Java application for a quick introduction to IntelliJ IDEA's debugger.

    • Run static analysis to see where incorrect values might be coming from.

  • If a logic error is present, the debugger may save you a lot of time finding and fixing the cause. See Tutorial: Debug your first Java application for a quick introduction to IntelliJ IDEA's debugger.

  • If the problem is related to application performance, IntelliJ Profiler will help you analyze the problem and assess the efficiency of a fix.

Show running processes

You can view the list of all active run or debug sessions and navigate between them.

  • Go to Run | Show Running List. In the top-right corner of the editor, IntelliJ IDEA shows a list with all active applications.

CPU and Memory Live Charts

IntelliJ IDEA provides a way to monitor live performance statistics for a running process through CPU and Memory Live Charts.

As opposed to viewing static figures, live data may help you to visualize resource consumption, identify resource-related bottlenecks, and understand how certain events affect the program performance.

For example, in the picture below, we can see what a memory leak looks like in the Heap Memory chart. Sometimes it is enough to figure out the cause, and when it is not enough, it can give a clue for further investigation.

Memory leak on CPU and Memory Live Charts

CPU and Memory Live Charts are automatically shown for all programs that you run from IntelliJ IDEA:

CPU and Memory Live Charts in the Run tool window

For more information, refer to Monitor resources usage.

Last modified: 12 November 2024