I have a Windows executable written in C++. It loads libJVM as a shared library, and then executes a java program via JNI. I want to debug that java program, using Eclipse IDE. How can I do that? As a last resort, I even can modify the C++ program.
-
1You need to start the JVM in debug mode and specify the port you can connect to. Eclipse should help you give you the command line options you need to provide to make this happen. I would strongly suggest you have a means of running the JVM without C++ as well, if only for testing purposes.Peter Lawrey– Peter Lawrey2016-11-02 20:36:12 +00:00Commented Nov 2, 2016 at 20:36
-
1Is it necessary to remote debug starting from the C++ program? Why not run the java program directly in Eclipse with the incoming parameters passed by the C++ program?Andrew S– Andrew S2016-11-02 21:24:10 +00:00Commented Nov 2, 2016 at 21:24
Add a comment
|
1 Answer
I think you need to add debug parameters to that JavaVM instance that is created by your C++ code.
Eclipse native launcher code can inspire your work. Have a look at Windows version of the launcher and inspect startJavaJNI function (line 305). There is path to the library libPath and parameters vmArgs. I suppose that vmArgs can contain the usual -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4242 string among other options.
You need to translate this into additional JavaVMOption element in JavaVMInitArgs.