Symbian
Symbian OS Library

FAQ-0241 How can I do runtime debugging of my JNI code?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: JNI
Created: 06/30/99 Modified: 09/04/2001
Number: FAQ-0241
Platform: ER5, Symbian OS v6.0, Symbian OS v6.1

Question:
I have successfully compiled and linked a Java app which accesses native code through JNI, using nmake as in the PowerInfo example. But without a MSVC project, how can I obtain runtime debug information?

Answer:
You can do this by creating a default MSVC project for your native code and launching the emulator from within that as you would with a normal EPOC project.
Open the C++ source file you want to debug in MSVC6. Hit F5 as if to carry out a debug session. As there is no project open, you will be prompted to create one. Select "Yes". You will be invited to build a .exe file. Select "No". Check the active configuration ("Build | Set Active Configuration") is set to "debug".

Next you should specify the location of the executable and of the DLLs containing the code you want to debug. Select "Project | Settings" (alt-F7) and choose the "Debug" tab. Under the "General" category, set the executable by clicking on the arrow at the right of the relevant box and browse to \epoc32\release\wins\deb\java_g.exe. (appletviewer_g.exe can be used for applets here.) For "Program arguments", type in -cp where, in the case of the PowerInfo example in the SDK, would be j:\examples\powerinfo and would be PowerInfo. Under the "Additional DLLs" category, click on the blue rectangle then the "..." button which appears and browse to your DLL. This should be located in \epoc32\release\wins\deb. For a library called powerinfo, the DLL would be called powerinfo_g.dll. Select this and any other DLLs you might want to debug, then hit OK. Extra source files files can be included for debugging with "Project | Add to Project | Files".

When you hit F5 again your Java class should get launched in the emulator and should stop at any breakpoints you have set in your source code as with a normal EPOC project.