Posts Tagged ‘debug’

Viewing complete strings while debugging in Eclipse

February 14, 2017

While debugging Java code, Strings in the views “Variables” and “Expressions” show up only till a certain length, after which Eclipse shows “…”. Even after working with eclipse for 10 years it was a new info for me. There is a way to show the complete string.

In the Variables view you can right click on Details pane (the section where the string content is displayed) and select “Max Length…” popup menu. The same length applies to expression inspector popup and few other places. In the max length give 0 and you will see the whole values in the value box.

untitled

Thats it guys, enjoy coding.

Debug using Apache Tomcat and Eclipse

May 16, 2011

It is always useful to debug the code in a line by line fashion to track where the code went wrong. Since I am using Apache Tomcat server for development purpose this article deals with enabling debugging on Apache Tomcat with Eclipe IDE.

First we need to set up the Tomcat server to enable debugging. Usually the debugging port used for tomcat is 8000, but you can set to any free port.

1. Open the startup.bat file from Tomcat directory (<Tomcat Installation Directory>/bin/)

2. After the script initializes the command line arguements, most probably towards end of file, add these two lines :

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket

3. Change the line where it calls the EXECUTABLES to :

call “%EXECUTABLE%” jpda start %CMD_LINE_ARGS% (add jdpa start).

Save the file and start the tomcat. Now the first line of the tomcat startup console will show :

Listening for transport dt_socket at address: 8000

At this point your Tomcat server is ready to be run in debug mode. Now do the following steps at Eclipse IDE for debugging in Eclipse.

1. Open one class where you want to put breakpoint and add one breakpoint. (This can be done by clicking on the left margin on the corresponding line.

2. From Run menu, select Debug Configurations

3. From the left side, right click on Remote Java Application and click new

4. Fill out the form appearing. Only thing to take care is the server name should be localhost and port number 8000. This can be changed if you are debugging on a remote server.

5. Click on debug and now the eclipse is running in debug mode.

Now you can run the application and whenever the thread reaches the line, where you have put the breakpoint, it will pause execution. Then you can see the current values of the variables, you can step by step execute the line and so on.

That’s it guys. Happy Coding 🙂


%d bloggers like this: