Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-01-2004, 12:19 PM   #1
Registered: May 2003
Distribution: RedHat
Posts: 60

Rep: Reputation: 15
Debugging C++ so called from java program


I'm working on a project which consists of a java layer and a C++ library which we build as a shared object on Linux. The java code accesses the Shared Object via JNI. We port the native stuff to several platforms including RedHat Linux and Windows. In the Developer Studio on Windows I can set a breakpoint in one of the C++ files and then direct the debugger to launch the calling Java process. I'd really like to be able to debug the native portion on Linux but I can't seem to make it work with gdb. Is it possible, then, to debug a shared object using gdb by launching a java process? Thanks in advance for any replies.

Old 12-14-2004, 02:00 PM   #2
LQ Newbie
Registered: Dec 2004
Posts: 16

Rep: Reputation: 0
Short answer: yes
Long answer:

- start gdb
- make gdb stop whenever any shared library is loaded
(gdb) set stop-on-solib 1
- run your java application with arguments
(gdb) file java
(gdb) set args ... MyClass
(gdb) run
- whenever gdb stops, check whether your JNI library
has been loaded
(gdb) info shared
- if JNI library is not on the above list, do continue
- if JNI library is on the above list, issue a breakpoint
(gdb) break Java_MyClass_....
(gdb) continue
- you are now inside JNI route debugging it with GDB
Old 01-03-2005, 03:00 PM   #3
Registered: May 2003
Distribution: RedHat
Posts: 60

Original Poster
Rep: Reputation: 15
Thanks Stanley! That worked great.
Old 10-12-2005, 03:01 PM   #4
LQ Newbie
Registered: Oct 2005
Posts: 7

Rep: Reputation: 0
JAVA JNI program to access shared library

I was viewing postings related to JNi and found that it is similar to what I am doing.

I you don't mind, take a look at teh problem described below, and tell me how to access my shared C++ library that is accessed via JNI calls from JAVA.


Here is the problem description:

Operating system: Red Hat Linux 2.4.21-4.EL.
GUI interface: GNOME

I am writing a JAVA JNI program using JDK 1.5.0_04 version and netbeans 4.1 IDE. I am trying to access a shared library called "" that was written in GCC compiler.

I have placed this "" library in the JAVA CLASSPATH

I used the statement : System.loadLibrary("dfa");

- when I run the program from within netbeans, I get the error message :

Exception in thread "main" java.lang.UnsatisfiedLinkError: no dfa in

* Is there any more environment varaibales I need to set ?

* Where do I place my ""?

* Is this the right syntax?

- Using GUI Natutilus 2.2.4 ( a graphical shell for GNOME), I tried to run
The jar file by double clicking on it, and nothing happens. It won't run.

* How do I run it from the GUI session?

Thanks in advance.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Do YOu Know a program Called SIG? benmay05 Linux - Software 2 06-27-2005 04:35 PM
Why is it called sun JAVA desktop system? sh1ft JDS 35 03-05-2005 02:39 AM
passwordcracking program called slurpie Israfel2000 Linux - Software 3 11-26-2004 08:37 AM
Debugging Java MadCactus Programming 1 09-16-2004 03:58 PM
Debugging Multithreaded Program villie Programming 2 08-17-2004 11:24 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration