In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to use the IDEA editor to debug remote Java code", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to debug remote Java code using the IDEA editor.
Configure local parameters
Open the "Run/Debug Configurations" option of IDEA, and configure the IP and port of the remote server, as follows
Don't worry about the content in the red box for the time being. The next step is to enter the ip of the remote server in the first input box in the green box and the port of the remote server in the second input box.
Configure remote server parameters
Log in to the remote server, open the catalina.sh file under the bin folder of tomcat for editing, and add the following parameters from the red box in the first step to configure the equal sign above export JAVA_OPTS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8185'.
In most cases, use the contents of the first input box in the red box as the parameter if the jdk on the remote server is version 1.4, use the contents of the second input box in the red box as the parameter if the jdk on the remote server is version 1.3, use the content of the third input box in the red box as the parameter
Debug
Start the IDEA service configured in the first step, put a breakpoint on the code to be debugged, and enter the breakpoint when the program on the remote server is accessed, then you can debug happily
To start the IDEA service, click the following button
After IDEA starts successfully, the console outputs the following
Parameter interpretation
The following is a screenshot of the configuration in the first step. Let's explain the meaning of each of the following parameters one by one.
Let's start with the parameters in the green box.
Transport is the communication method between IDEA and the remote server. Select socket if the remote server is linux or macos, and Shared memory if the remote server is windows.
Options for Debugger mode are Attach and Listen. Attach means the server starts up and waits for the IDEA to connect; Listen means the IDEA listens on the port of the server and will establish a connection when the server is ready. This way requires the server to ping the ip of the local computer. Attach mode is usually used.
Host is the ip,Port of the remote server is the port of the remote server.
Besides, the parameters in the red box
The parameters in the red box are not allowed to be modified manually, it changes with the modification of the parameters in the green box.
-Xrunjdwp: tells JVM to use jdwp (java debug wire protocol) to run the server code transport. Available values are dt_socket and dt_shmem, corresponding to Socket in the green box and Shared memoryaddress corresponding to Port in the green box, which is the port of the remote server.
Matters needing attention
1. The port on the remote server must not be occupied and can be accessed locally and can pass telnet tests, such as telnet remote ip remote port 2. The code deployed on the remote server must be consistent with the local source code, otherwise the breakpoint cannot be accessed
3. When configuring a remote server, if the JAVA_OPTS parameter already exists in catalina.sh, you only need to append the parameter to be configured later. At this point, I believe you have a deeper understanding of "how to use the IDEA editor to debug remote Java code". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.