Bookmark Topic Watch Topic
  • New Topic

How to Connect C using (JNI) java native Interface??

 
dhana sss
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Report post to moderator
i want to connect C program to java using java native Interface.
this is my codding:

HelloWorld.java

class HelloWorld {
private native void print();
public static void main(String[] args) {
new HelloWorld().print();
}
static {
System.loadLibrary("HelloWorld");
}
}

Helloworld.c

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

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

HelloWorld.h

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */

#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: print
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_print
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif


hai all i need only the JNI.h file . if any one have please send me the link or send me the txt file to my mail ID : dhana_java@yahoo.com

by
dhana
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not crosspost the same question in multiple forums.
This topic is now closed. You can continue the discussion at:
http://www.coderanch.com/t/272606/java/java/include-JNI-java-native-interface
 
    Bookmark Topic Watch Topic
  • New Topic