通过Java和C之间的数据 [英] pass data between Java and C

查看:87
本文介绍了通过Java和C之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C结构。

struct data{
    double value1[50];
    double value2[50];
    int count;
};

我想从Java数据映射到该C structure.How它使用JNI我能做什么?
在java code将不是由我来编程。 Java程序员只是想知道以何种形式,他应该给我的数据?他应该期待的更多细节。

I want to map data from java to this C structure.How can I do it using JNI? The java code will not be programmed by me. The java programmer just wants to know in which form should he send me the data? Should he expect any more details

我目前用含2列的CSV文件填充结构实例测试我的code。

I am currently testing my code by filling the structure instance with a CSV file containing 2 columns.

我也想从我的C code返回3 double值的Java应用程序。

I also want to return 3 double values from my C code to the java application.

推荐答案

提供以下声明,以你的java程序员:

Provide the following declaration to your java programmer:

public native double[] doData(double [] value1, double [] value2, int count);

在你的c code,你将能够传递的参数,以填补结构。 JNI头看起来像这样:

In your c code you will be able to fill the structure with passed parameters. JNI header will look like this:

JNIEXPORT jdoubleArray JNICALL Java_package_className_doData(JNIEnv * , jobject, jdoubleArray , jdoubleArray, jint);

这篇关于通过Java和C之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆