Patricia
Patricia

Reputation: 5089

Run/Debug Maven JavaSE application in Netbeans

I have a JavaSE multi-module application that I want to build and run in debug mode. Then once the application is running (on my local machine) I want to be able to attach to the process. We are using Maven and the IDE is Netbeans.

I've already found this information:

You can debug any Maven goal in NetBeans going to /Project Properties/Actions/, select the goal you wan to debug, in the last option Set Properties choose Add, and then select Debug Maven build.

However, I don't know what to enter for the Execute Goals to get it to run in Debug mode. I can select Run -> Clean and Build Maven Project and see that my projects are being built in debug mode (i.e., [debug] execute contextualize).

I found an answer somewhere out here that said the default port for the local machine in 8000. So how do I get the application running on that port, so I can attach to it?

enter image description here

Upvotes: 4

Views: 8301

Answers (2)

luisacevedo
luisacevedo

Reputation: 242

if you are using spring boot this worked for me:

  1. from command line go to your project parent folder
  2. run mvnDebug spring-boot:run
  3. from netbeans run debug attach debugger with this values:

Debugger: Java Debugger (JDPA),

Connector: SocketAttach (Attaches by socket to other VMs),

Transport: dt_socket,

Host: localhost,

Port: 8000

Upvotes: 1

cbangor
cbangor

Reputation: 140

Not sure if this is the answer you want.

  1. Your multi-module application must have one maven module (jar type) which contains the code (the main class) to launch your application.
  2. Right click that module and see the properties page as you show above. (I think what you opened is a POM type module.)
  3. You should have a Run Category to allow you to add JVM arguments.
  4. Add the JVM parameter (something like: -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y)
  5. Run your application in NetBeans.

Hope this will help.

Upvotes: 3

Related Questions