I recently got the chance to setup Java debug environment for Java-COM based Windows application. Here the VB6 code is used for showing the User interface of application while Java and C++ code includes business logic of the application. To fix some bugs in the application, a debug environment was required which allows users to debug Java and C++ JNI code.
Using the Code
To debug C++, I used Visual Studio attach to process method and for Java code remote Java debugging of Eclipse was used.
Here are the details of the process that I used to debug Java.
We need to implement the following two steps:
- Launch the application and tell the JVM that it will be debugged remotely
- Create debug configuration in Eclipse IDE to debug application remotely. (in our case, it is localhost)
Pass the following argument to JVM:
The above code should be placed at the location where JVM is loaded in the code.
8998 denotes the port and
suspend=n will make sure that the debugging is suspended till the Java code hits in the application.
In the Eclipse IDE, we need to create a new debug configuration and enter the following details in Connection Properties:
- Host - localhost
- Port - 8998
Now, click on apply, then launch the application. Now click on Debug in Debug configuration after setting debug points in the Java code.
Points of Interest
Using the above steps, we can debug the C++ and Java code simultaneously. This helped to understand proper functions flow in application.