tags:

views:

154

answers:

3

How to debug the JNI code in VisualStudio 2003 without using eclipse?

+2  A: 

http://www.velocityreviews.com/forums/t152740-jni-debugger.html

SUMMARY: Basically, the idea is that you start your Java program under Eclipse, and then tell VC to attach to the running process too.

adatapost
+2  A: 

Start your application and let your application wait for a user action (dialog or something). Open VS and go to (in German) "Debuggen" (Debugging) -> "Prozesse" (Processes) Their you will see the javaw.exe

Select the javaw.exe and and press "Anfügen" (Attach)

Let your java application run.

When i remeber, the code page in c++ wher the breakpoint is placed has to be open in VS. VS will not open the page when the breakpoint is hit automaticaly. When the dll is loaded and the code line where you put a breakpoint is executed, the debugger in VS will stop at this position. Notice: this will only happen, when you compile the dll you want to debug in with debug options!!! otherwise the debugger will not stop at the C++ breakpoint.

I did this half a year ago, but this should be the right steps.

It hope you get it.

Markus Lausberg
+1  A: 

You've got two options:

  1. as described in Markus Lausberg's answer, you can start up the Java process and attach the VS debugger to it.
  2. The other option is to use Visual Studio's project settings to specify java.exe as the program to execute when debugging. Put the necessary class paths and everything else you'd pass to Java into the command line, set the working directory and when you start the debugger, it'll fire up Java, trap the load of your JNI dll and breakpoints etc will work as expected.
Timo Geusch