User Tools

Site Tools


make:makefile-java-and-c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
make:makefile-java-and-c [2024/01/15 21:19] – created odeftamake:makefile-java-and-c [2024/01/15 21:23] (current) odefta
Line 52: Line 52:
 </code> </code>
  
 +To compile the programs:
 +<code>
 +make
 +</code>
 +
 +To run the program:
 +<code>
 +make run
 +</code>
 +
 +To cleanup the built files:
 +<code>
 +make clean
 +</code>
 +
 +Hello.java:
 +<code java Hello.java>
 +public class Hello {
 +    private native void sayHello();
 +
 +    static {
 +        System.loadLibrary("hello");
 +    }
 +
 +    public static void main(String[] args) {
 +        new Hello().sayHello();
 +    }
 +}
 +</code>
 +
 +<code c hello.c>
 +#include <jni.h>
 +#include "Hello.h"
 +
 +JNIEXPORT void JNICALL Java_Hello_sayHello(JNIEnv *env, jobject obj) {
 +    printf("Hello from C!\n");
 +}
 +</code>
make/makefile-java-and-c.1705346366.txt.gz · Last modified: 2024/01/15 21:19 by odefta