I thought that I would expand these answers for OSX and Linux people (not that they need it):
I also prefer using mvnDebug . But after OSX Maverick destroyed my Java development environment, I started from scratch and came across this post, and thought I'd add to it.
$ mvnDebug vertx:runMod -bash: mvnDebug: command not found
Doh! I did not install it in this field after a new SSD and / or reset all Java when I installed Maverick.
I use the package manager for OSX and Linux, so I have no idea where mvn actually lives. (I know for short periods of time .. thanks, brew. I like that I don't know that.)
Let's watch:
$ which mvn /usr/local/bin/mvn
There you are ... little b @stard.
Now where did you install:
$ ls -l /usr/local/bin/mvn lrwxr-xr-x 1 root wheel 39 Oct 31 13:00 / /usr/local/bin/mvn -> /usr/local/Cellar/maven30/3.0.5/bin/mvn
Yeah! So you installed in /usr/local/Cellar/maven30/3.0.5/bin/mvn. You're a cheeky little build tool. Homegrown no doubt ...
Do you have your little mvnDebug buddy with you?
$ ls /usr/local/Cellar/maven30/3.0.5/bin/mvnDebug /usr/local/Cellar/maven30/3.0.5/bin/mvnDebug
Good. Good. Fine. Everything goes according to plan.
Now move this little b @ star to where I can remember it easier.
$ ln -s /usr/local/Cellar/maven30/3.0.5/bin/mvnDebug /usr/local/bin/mvnDebug ln: /usr/local/bin/mvnDebug: Permission denied
Damn it, computer ... You will obey my will. You know who I am? I A COURT! ONION!
$ sudo ln -s /usr/local/Cellar/maven30/3.0.5/bin/mvnDebug /usr/local/bin/mvnDebug
Now I can use it from Eclipse (but why should I do this if I have IntelliJ !!!!)
$ mvnDebug vertx:runMod Preparing to Execute Maven in Debug Mode Listening for transport dt_socket at address: 8000
Internally mvnDebug uses this:
MAVEN_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE \ -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
So you can change it (I usually debug on port 9090).
This blog post explains how to set up remote Eclipse debugging (shudder)
http://javarevisited.blogspot.com/2011/02/how-to-setup-remote-debugging-in.html
Same netbeans
https://blogs.oracle.com/atishay/entry/use_netbeans_to_debug_a
Same IntelliJ http://www.jetbrains.com/idea/webhelp/run-debug-configuration-remote.html
Here are some good documents on the -Xdebug command in general.
http://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html
"-Xdebug provides debugging capabilities in the JVM that are used by the Java Virtual Machine Tool Interface (JVMTI). JVMTI is the low-level debugging interface used by debuggers and profiling tools. With it, you can check the status and monitor the execution of applications running in the JVM."
"The JVMTI subset that is most often used by profilers is always available. However, the functionality used by debuggers to enable step-by-step code execution and setting breakpoints has some overhead and is not always available. You must use the -Xdebug option to enable this function."
-Xrunjdwp:transport=dt_socket,server=y,suspend=n myApp
Check the docs on -Xrunjdwp too. You can enable it only when, for example, a specific exception is thrown. You can start it paused or running. Anyway .. I was distracted.