Solved

How to pass *FileData(pointer) from Java to C

Posted on 2014-03-17
1
459 Views
Last Modified: 2014-03-20
I have to get some useful response data from a native library written in C.

I am not able to see how to pass (* fileData i.e. (pointer to fileData )) from java to C.
//1) NameofFile.c
int pspLoadFiles(PSPlusFileData* fileData)


//1) Java native method :-
public native int pspLoadFiles(java.io.File file );

//2) Generated Header File:-
/*
 * Class:     JavaTestClass
 * Method:    pspLoadFiles
 * Signature: (Ljava/io/File;)I
 */
JNIEXPORT jint JNICALL Java_JavaTestClass_pspLoadFiles
  (JNIEnv *, jobject, jobject);

Open in new window


Error:-
java.lang.UnsatisfiedLinkError: pspLoadFiles
        at JavaTestClass.pspLoadFiles(Native Method)
        at JavaTestClass.main(JavaTestClass.java:30)

How could we pass this fileData to C function.

thanks
Vishnu
0
Comment
Question by:jgdvishnu
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39936105
I have to get some useful response data from a native library written in C.

I am not able to see how to pass (* fileData i.e. (pointer to fileData )) from java to C.
You can't do it directly! You can't create some arbitrary C/C++ object (ie. PSPlusFileData) in Java and pass it to the native function. Any C/C++ objects need to be created in your native code.

What you need to do, is implement the Java_JavaTestClass_pspLoadFiles function in you C code to convert the information obtained from the Java File object passed in (via the jobject parameter) into the required information in your PSPlusFileData object.

And then, once this is done, that C function can call the real pspLoadFiles function with the pointer to PSPlusFileData that you have just setup.

I can't really help you much further without knowing anything about this PSPlusFileData class?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 102
eclipse argument 14 53
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 56
java jdbc batch example 8 22
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now