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 6368223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:38:53+00:00 2026-05-25T00:38:53+00:00

These are the incomplete steps that i have followed to call a native function

  • 0

These are the incomplete steps that i have followed to call a native function from a java program.

  1. Wrote a java program and then compiled to the .class file
  2. From the command javah - jni i generated a header file with the same name as .class file.
  3. After that i opened a Microsoft Visual C++ Express , started a new project and set my application type to dll.

This is the java program that calls the native c method.

class HelloWorld {

private native void print();

public static void main( String args[] ) {
  new HelloWorld().print();
}

static {
  System.loadLibrary("??"); // what should i write here ?
}

}

And this is the c program

#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"

JNIEXPORT void JNICALL 
Java_HelloWorld_print( JNIEnv *env , jobject obj) {
  printf("Hello World!\n");
  return;
}

I kept the project name as jni tester and the c file name is HelloWorld.c

In the statement System.loadLibrary(??) What should be the name of the library in the argument ? (Or is there any step that i am missing before i can fill the argument of loadLibrary)

If so what is that i am missing ?

  • 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-05-25T00:38:53+00:00Added an answer on May 25, 2026 at 12:38 am

    From that function’s documentation
    System.loadLibrary:

    Parameters:

    libname – the name of the library.

    You pass it the name of your DLL. (That is, the DLL’s filename without the .dll extension. On Unix-like systems, it would be the shared object name without the lib prefix or the .so (or .o for some platforms) extension.)

    Make sure your JVM can find the DLL in its library path. To change the library path, you can use the java.library.path system property like this:

    java -Djava.library.path=directory_where_your_dll_resides ...
    

    [Doing this and dropping the extension from the library name keeps the java side of your code as portable as possible. You’ll be able to move it as-is to another platform, only needing to rebuild the JNI part for that target.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

These are some questions for any developer whose made the jump from Java to
I'm using a Java class library that is in many ways incomplete: there are
I'm wondering. If I have a form that is broken up into steps where
I have a project on my hand with some libraries that are compiled as
These two may look like they have no correlation but bear with me! In
I have a list of incomplete ordered numbers. I want to find a particular
i have a huge .java file and i want to find all declared objects
I have a JLabel that needs to display some html-formatted text. However, I want
I have a database that has two tables, one of which contains a foreign
I noticed that the source code shown in Firefox appears to be incomplete. I

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.