I have a tomcat running after making configuration and when I type jdb in terminal it says initializing. So I like to know
How to attach jdb with tomcat and specify servlet name.
What is the compile option (like in C its eg. -g with gdb) to include debugging symbols when compiling servlet with
javac
I have opt/tomcat/apache-tomcat-10.0.10 so I guess Tomcat version is 10
The
javaccommand switch to add all debugging symbols is ...-g. Line numbers and source file names are actually added by default, you only gain information on local variables (see this question).You can not connect a debugger to a running JVM, unless it was started with the appropriate command line option (see this question).
Tomcat has a helper script
bin/catalina.shthat can help you start it with the correct parameters:catalina.sh jpda startstarts Tomcat in the background with debugging enabled. You can connect to it with:catalina.sh jpda runworks as in the previous case, but in the foreground,catalina.sh debugstarts Tomcat throughjdb. You just need to userunto start it.Once you are connected you can use:
to add break points.
Remark: Both
javacandjdbare not often used these days. Most people use tools like Ant, Maven, Gradle, etc. to compile their projects and IDEs to debug the code.