In order to debug Java classes that are called during MATLAB execution, it is necessary to perform two steps:
When MATLAB is started in JVM debugging mode, the following message appears in the command window:
JVM is being started with debugging enabled. Use "jdb -connect com.sun.jdi.SocketAttach:port=4444" to attach debugger.
Create a shortcut to the MATLAB executable (
matlab.exe) and add the
-jdb flag at the end as shown below:
When running MATLAB using this shortcut JVM debugging will be enabled.
java.opts file can be created/updated. This file is stored in "matlab-root\bin\arch", where "matlab-root" is the MATLAB installation directoy and "arch" is the architecture (e.g. "win32").
The following should be added in the file:
Attaching this debugger requires the creation of a "remote debugging" configuration with the port exposed by MATLAB:
Then the debugger is started:
If everything is working as expected, the following message will appear in the console: