Tutorial - Remote Debug - IntelliJ IDEA
Tutorial - Remote Debug - IntelliJ IDEA
Tutorial - Remote Debug - IntelliJ IDEA
IDEA
IntelliJ IDEA 2022.2
In this tutorial, we'll learn how to attach to a local or remote process using the
IntelliJ IDEA debugger.
Create a project
First, let's set up the project that we'll be debugging (a simple program that outputs the
capital letters from A to Z ).
You can use your own project instead of the one created in this chapter. If you
do, make sure that:
• the app is compiled with debug information. This is the default compiler
setting and must not be overridden. Otherwise, most of the debugger
functionality will be unavailable.
• you have the source code of the application. While it is possible to use
decompiled code for debugging, it is more complicated and not covered in
this tutorial.
[X]
Cookies and IP addresses allow us to deliver
and improve our web content and to provide you with a
personalized experience.
Our website uses cookies and collects your IP address for these purposes.
Learn more
1. Create a new project.
JetBrains may use cookies and my IP address to collect individual statistics and to provide me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
2. Create
third-party a class
services for named Alphabet
this purpose. .
I can revoke my consent at any time by visiting the Opt-Out
page.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 1/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
3. In the body of the Alphabet class, paste the following definition of the main
method:
System.out.println("Starting");
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println(c);
System.out.println("Complete");
Though
JetBrains may we are
use cookies andrunning and debugging
my IP address the application
to collect individual on the
statistics same
and to machine,
provide me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
third-partythe stepsfor
services arethis
thepurpose.
same for debugging
I can revoke my an application
consent thatbyis visiting
at any time indeed the
remote.
Opt-Out
page.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 2/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
1. From the main menu, select Run | Edit Configurations or press Alt+Shift+F10
then 0 .
• Name: configure how this run configuration will be called. The name can be
anything, including the default value.
• Host: the address of the machine where the host app will run. Since we are
running it on the same machine, it needs to be localhost. If the program was
running on another machine, we would specify its address here, for example:
192.168.17.43.
• Command line arguments for remote JVM: the VM options that the host
application needs to be started with. We will use them in the other run/debug
[X]
Cookies
configuration. You can copy them now or get back to this field later.
and IP addresses allow us to deliver
and improve our web content and to provide you with a
personalized experience.
Our website uses cookies and collects your IP address for these purposes.
Learn more
JetBrains may use cookies and my IP address to collect individual statistics and to provide me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
third-party services for this purpose. I can revoke my consent at any time by visiting the Opt-Out
page.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 3/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
4. Click Apply.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 4/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
2. Click Modify options, then select Add VM options. In the VM options field,
paste the options that you copied from the debug configuration.
3. Click Apply.
personalized experience.
Our website uses cookies and collects your IP address for these purposes.
Learn more
Now that we prepared all that is necessary, we can proceed with running our
JetBrains may use cookies and my IP address to collect individual statistics and to provide
application. me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
third-party services for this purpose. I can revoke my consent at any time by visiting the Opt-Out
page.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 5/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
This indicates that we have enabled the debug agent and our program is ready to
accept incoming debugger connections.
Attach to process
1. Click the gutter at line 10 to set a line breakpoint there.
[X]
Cookies and IP addresses allow us to deliver
and improve our web content and to provide you with a
personalized experience.
Our website uses cookies and collects your IP address for these purposes.
Learn more
JetBrains may use cookies and my IP address to collect individual statistics and to provide me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
third-party services for this purpose. I can revoke my consent at any time by visiting the Opt-Out
page.
[Yes,2.
I agree]
Press [No, thanks]
Alt+Shift+F9 and select your remote debug configuration.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 6/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
As the result, the program is suspended at the breakpoint, and you can perform any
debugging actions like stepping, expression evaluation, and so on.
The debugging process is the same regardless of how and where your app is launched.
After you have connected, you can use the same debugger features as if you were
launching your app right from IntelliJ IDEA.
JetBrains may use cookies and my IP address to collect individual statistics and to provide me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
third-party services for this purpose. I can revoke my consent at any time by visiting the Opt-Out
page.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 7/8
19/09/2022, 10:15 Tutorial: Remote debug | IntelliJ IDEA
• Disconnect stops the debug session and the process continues to run.
• Terminate stops both the process and the debug session.
[X]
Cookies and IP addresses allow us to deliver
and improve our web content and to provide you with a
personalized experience.
Our website uses cookies and collects your IP address for these purposes.
Learn more
JetBrains may use cookies and my IP address to collect individual statistics and to provide me with
personalized offers and ads subject to the Privacy Policy and the Terms of Use.
JetBrains may use
third-party services for this purpose. I can revoke my consent at any time by visiting the Opt-Out
page.
https://www.jetbrains.com/help/idea/tutorial-remote-debug.html 8/8