I am currently developing an MVC Application using Java EE Technologies and Eclipse as an IDE. To run my server and deploy my application I am using ANT. I would like to know how can I debug my Java Code through the ant tool or eclipse.
Asked
Active
Viewed 1,856 times
2 Answers
2
Add the following jvmarg
options to your tomcat start command:
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n"/>
You will be able to attach the Eclipse debugger on port 5000, using the Remote Java Application
debug category.

Strelok
- 50,229
- 9
- 102
- 115
-
Is it easier to run it from Eclipse without using ant? What should I do for that? In ANT I had configured all my external Jars to be in WEB-CONTENT/WEB-INF/LIB, but I imagine that in order for being able to run it directly from Eclipse, I sould place this external libraries somewhere else. – user1084509 Dec 07 '11 at 23:13
-
@user1084509 I prefer to run everything from `ant` because this way you already have everything configured and you don't need to maintain ant and Eclipse in sync. You can add the `ant` view window to eclipse and just run your ant task from within Eclipse. – Strelok Dec 07 '11 at 23:16
1
You can do that from eclipse:
- enable debug on tomcat
- create a new debug configuration in eclipse that connects to tomcat
See here for details.
But it is not a good idea to use ant to start tomcat in development. Use Eclipse WTP to start your tomcat and deploy applications on it.

Bozho
- 588,226
- 146
- 1,060
- 1,140
-
Thank you very much for your answer. As I mentioned before, Im using ANT to start apache. Do you know how can I enable debug mode in tomcat via my ant start command? My ant task looks as follows:
Starting Tomcat -
-
I would like to follow your advice of not using ANT. I already configured my server in Eclipse, the problem now is that when trying to run my application, it doesn't find any servlet. What should I do to compile my classes, build the proyect and start running it? The option Project - Build all is disabled – user1084509 Dec 07 '11 at 23:11
-
you have to configure the deployment assembly of the project. Look for a WTP tutorial to see how – Bozho Dec 08 '11 at 06:57