2

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.

2
  • 1
    You 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. Commented Nov 2, 2016 at 20:36
  • 1
    Is 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? Commented Nov 2, 2016 at 21:24

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.