Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:18:44+00:00 2026-06-12T05:18:44+00:00

I am practising JNI and created the shared library file Samplelib.so. I added the

  • 0

I am practising JNI and created the shared library file Samplelib.so. I added the directory in which the library file is created, to the java.library.path and when I run the java file, I get java.lang.UnsatisfiedLinkError. Here is my Sample.java.

import java.util.*;
public class Sample{
public native int intmethod(int n);
public native String stringmethod(String s);
public static void main(String[] args) {
    try{
    //System.setProperty( "java.library.path", "/home/sudhagar/Project" );
    System.load("libSample");
    Sample sample=new Sample();
    int sq=sample.intmethod(2);
    String text=sample.stringmethod("JAVA");
    System.out.println(sq);
    System.out.println(text);
}
catch(UnsatisfiedLinkError e){
    String property = System.getProperty("java.library.path");
    StringTokenizer parser = new StringTokenizer(property, ";");
    while (parser.hasMoreTokens()) {
    System.err.println(parser.nextToken());
    }
}
}
}

My Sample.c file,

#include "Sample.h"
#include <string.h>

JNIEXPORT jint  JNICALL Java_Sample_intmethod
(JNIEnv *env, jobject obj, jint n){
    return n*n;
}

JNIEXPORT jstring JNICALL Java_Sample_stringmethod
(JNIEnv *env, jobject obj, jstring n){
    return n;
}   

void main(){}   

I used following command to create the create the shared library,
gcc -shared -I/…/include -I/…/include/linux -o libSample.so Sample.c

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:18:45+00:00Added an answer on June 12, 2026 at 5:18 am

    Use

      System.loadLibrary("Samplelib");
    

    instead of

    System.load("Samplelib");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a new File in Eclipse using the following Java
practising some python, which is a pretty easy language to grab up. I have
I'm practising Django now, and I'm stuck. When I run: >>> from django import
I am practising from LYAH. phoneBook.hs file contains following code: phoneBook :: [(String, String)]
i was practising to create,store and get data's from database, i am successful in
I'm practising with C, writing simple programs. The little program below should just get
I am practising Oracle JDBC using Java in Eclipse. I understood how to output
I am practising JSF. I created a login screen with user Id and password
I'm practising HTTP using Sockets in C# and i'm able to get the response
I was practising statements and ran into a problem. I'm trying to make it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.