A better way to debug JNI dynamic libraries in Linux?

  • From: Joseph Areeda < >
  • To:
  • Subject: A better way to debug JNI dynamic libraries in Linux?
  • Date: Mon, 19 Nov 2012 07:06:09 -0800

Greetings respected colleagues,

I'm working on my first JNI library.  Things are actually going very well, but I get the feeling there has to be a better way to use the C++ debugger.

I have a C++ project that generates the dynamic library and a separate Java project that has the wrappers and a pretty good set of JUnit tests. 

If I want to get a break point in the C++ code what I do now is:
  • Copy the part of the Junit code that fails to a separate application.  It's short.  Build a jar.
  • From a command line:
    • gdb java
    • set args -jar test.jar
    • b <big long auto generated name of JNI function>
    • Say yes to the prompt:
      Function "<big long auto generated name of JNI function>" not defined.
      Make breakpoint pending on future shared library load? (y or [n]) y

From there everything works as expected.

So 2 questions:

  1. Is it possible to do this from within the IDE?  The NetBeans interface to gdb is my friend.
  2. If not, how do you run JUnit tests from inside gdb? I know that's not really a C++ question, but I'll bet some of you have debugged JNI code.

Thanks for your time,



A better way to debug JNI dynamic libraries in Linux?

Joseph Areeda 11/19/2012

Project Features

About this Project

CND was started in November 2009, is owned by DimaZh, and has 186 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20160708.bf2ac18). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm