Solved

JNI

Posted on 1998-11-18
1
347 Views
Last Modified: 2013-11-23
I have been playing around with the Java Native Interfaces.All of the examples that I have seen have all used javah -jni....then include the created header file inside the C program.  Is there a way to access a C Library and pass stuctures from a java program  without editing a C program. All i have is the ".o".
0
Comment
Question by:smithc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
msmolyak earned 100 total points
ID: 1227726
If I understand you correctly, you need to interface with an existing C library from Java. The only way to do it is to create another shared library which will server as an intermediary between the Java app and the API you are trying to wrap or talk to.

Declaring native methods and then running javah -jni command allows you to generate the signatures of the functions the JVM will call when the native methods will be invoked in your Java program. You have to implement functions with those signatures. Those functions will have a benefit of being able to access the runtime environment and the object or class on which the method was invoked. That function in turn will call an existing C API passing it information from Java program, and then return the rsukts back to Java if necessary. That C function can manipulate Java instance variables on the available objects, call Java methods, create new Java objects andthrow Java exceptions.

I hope this answers your question.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question