This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes JNI Program RunTime Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "JNI Program RunTime Exceptions" Watch "JNI Program RunTime Exceptions" New topic

JNI Program RunTime Exceptions

Rajesh Kumar

Joined: Nov 16, 2001
Posts: 28
Hai friends
I am trying to call the Functionality from C program to Java Program using JNI
The C program is like
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
printf("Hello world!\n");

Java Program is
class HelloWorld
public native void displayHelloWorld();

public static void main(String[] args)
new HelloWorld().displayHelloWorld();
I compiled java program using this
and i made it as .h file using
javah -jni HelloWorld
Everything is fine but when i am trying to run the java program like this
java HelloWorld
It is saying exception
Exception is
java.lang.UnsatisfiedLinkError: no hello in shared library path
at java.lang.Runtime.loadLibrary(
at java.lang.System.loadLibrary(
at java.lang.Thread.init(

What shall i do to get the output
Please give me some suggestions
Rajesh Kumar
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Do you have the line you're using to compile the code? What directory are you putting the .dll/.so file in?
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Rajesh Kumar

Joined: Nov 16, 2001
Posts: 28
Dear Michael Ernest
Thankyou VeryMuch
The problem is that what u expressed.
Now I kept .dll file in the directory where class files and .h files stored.
now it is working fine.
Thankyou VeryMuch
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JNI Program RunTime Exceptions
It's not a secret anymore!