You may already know that you can set a breakpoint in eclipse for your java code, then have the program stop at the breakpoint in debug perspective, so that you can inspect the variable values or step through the code line by line. These are the basic usage of eclipse debugger. The following 7 tips will allow you do eclipse debug like a pro.
1. Change variable value
When a breakpoint is hit, you can right click a variable value then select "Change Value...".
2. Use breakpoint view
click Window -> Show View -> Breakpoint
In this tab, you can select/deselect breakpoints. High light one of the break point, you can set conditional match such as exceeding a certain hit count or matching a particular value.
For multi-threading program, "suspend VM" option allows you to exam the stack of the other threads. You can shift from one thread's stack to another thread's by clicking the thread name.
3. Use display view
click Window -> Show View -> Display
In this tab, you can write a few lines of code, highlight these code you want to run, then click the little triangle at the upper right corner to execute the code in the context of the breakpoint.
4. be able to inspecting code in project and depended jars.
If you are using maven project, install m2e plugin, then configure it to download both the source files and javadoc by going into Window > Preferences > Maven and checking the "Download Artifact Sources" and "Download Artifact JavaDoc" options.
You can search a class in project and depended jars with shortcut Command + Shift + T (mac) or Control + Shift + T (windows).
You can search a string in the workspace with shortcut Control + H.
You can search call hierarchy with shortcut Control + Command + H.
5. Remote debug
When you are trouble-shooting an application running in a remote machine. you need two piece of information: hostname or IP, the debugger port.
If you are not sure what port is the debugger port, you can login the hostname, then issue command
"netstat -nulpt | grep java " and see which ports the java application is listen to, then try these ports one by one.
6. set up tomcat to run local.
If your application produces a war file which can be deployed into tomcat, you can setup eclipse (J2EE) to integrate with tomcat and run your application local, then you can debug the code. To do so, download and unzip tomcat, in eclipse
Preference -> Server -> Runtime Environment
Click Add -> apache -> select the version matching the apache server you downloaded
Click next, browse to the directory of your downloaded apache server.
Click finish
Now you can run your j2EE project local by select Run -> Run As -> Run on Server
Click choose an existing server, then select your apache server from the server list.
Now tomcat will run your project's war file as a web container. Even with apache server configured, you program still need Arguments to be set correctly.
7. Use jrebel for quick deployment. JRebel fast tracks Java application development by skipping the time consuming build and redeploy steps in the development process.
This blog is about Ad-Hoc knowledge spreading to broad range of spectrum: software, electronics, computer hardware, wireless, system engineer, IoT, information security, NLP, Cloud, AI, ML, E-commerce, blog, search engine...Internet is ran by do good individuals, wish the knowledge be with you.
Subscribe to:
Post Comments (Atom)
Why I stopped publishing blog posts as information provider
Now the AI can generate content. Does that mean the web publishing industry reaches the end? ChatGPT said: ChatGPT Not at all. While AI can ...
-
1. Digg 2. Twitter 3. FriendFeed 4. Reddit 5. Hacker News 6. Facebook 7. MySpace 8. LinkedIn 9. Flixster 10. Flickr
-
It is super easy. On the top-right hand of youtube page, there is a textbox labeled "embed". Just copy the content in the textbox,...
-
Show   Hide Here is the text you would like to show --------------------------------------------------------------------------- I f...
No comments:
Post a Comment