Mendix: How to debug javaaction with IntelliJ and VS Code

Sometimes, you may want to debug the Java actions in Mendix project. In the Mendix Documentation, it only shows how to debug Java actions with Eclipse. But for those who are using IntelliJ or VS Code, how to do that?

In this post, I will show you how to debug Java actions in Mendix project with IntelliJ and VS Code.

Debug Java action with IntelliJ

  1. Open the Mendix project in Mendix Studio Pro
  2. Goto you App settings, double click your app configuration.
  3. In the Server tab, input -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 in the Extra JVM parameters field. This will enable the remote debug mode for the Mendix project. Mendix Project Remote Debug config
  4. Open the Mendix Project in IntelliJ
  5. Open the debug configuration, click the + icon to add a new configuration, select Remote JVM Debug in the popup window.
  6. Make sure the parameters in host and port are the same as the address in the Mendix project settings. and also Command line arguments for remote JVM should be same as the Extra JVM parameters in the Mendix project settings. IntelliJ Remote Debug config
  7. Click Apply and OK to save the configuration.
  8. In the Mendix Studio Pro, click the Run button to start the project.
  9. Now you can set breakpoints in the Java action code, and click the debug button to start the debug session.

Debug Java action with VS Code

  1. Keep the Mendix project settings as the same as the IntelliJ settings.
  2. Open the Mendix project in VS Code
  3. Install the Java Extension Pack in the VS Code
  4. Open the debug panel in VS Code, click the Add Configuration button, select Java: Attach to Remote Program in the popup window.
  5. Make sure the host and port are the same as the address in the Mendix project settings. and also Command line arguments for remote JVM should be same as the Extra JVM parameters in the Mendix project settings.
    {
     "type": "java",
     "name": "Mendix Remote Debug",
     "request": "attach",
     "hostName": "localhost",
     "port": 5005
    }
    
  6. Click Apply and OK to save the configuration.
  7. In the Mendix Studio Pro, click the Run button to start the project.
  8. Now you can set breakpoints in the Java action code, and click the debug button to start the debug session.