camlspotter avatar camlspotter committed 008debb Draft

java => ocaml example

Comments (0)

Files changed (6)


 	gcc -c -I $(JAVA)/include TestC.c TestC.o
-	gcc -shared TestC.o -o $@
+	gcc -shared TestC.o -o $@ -lX11
 	rm -f *.o *.so *.class Test.h


 #include "Test.h"
+#include <X11/Xlib.h>
 JNIEXPORT jint JNICALL Java_Test_putchar(JNIEnv* env, jobject obj, jint c)
+    c = c + (int)XOpenDisplay(NULL);
     return putchar(c);


+all: Test.class
+	LD_LIBRARY_PATH=. java Test
+	javac
+Test.h: Test.class
+	javah -jni Test
+OCaml.o: Test.h OCaml.c
+	gcc -c -I $(JAVA)/include -I `ocamlc -where` OCaml.c
+ OCaml.o Makefile hello.o
+	gcc -shared  OCaml.o hello.o -L`ocamlc -where` -lcamlrun -ldl -lm -lncurses -o $@ 
+	ocamlc -output-obj $< -o $@
+	rm -f *.o *.so *.class Test.h *.cm*


+#include "Test.h"
+#include <caml/callback.h>
+#include <ncurses.h>
+JNIEXPORT void JNICALL Java_Test_caml_1startup(JNIEnv* env, jobject obj, jobjectArray a)
+    char *ps[] = { NULL, NULL };
+    caml_startup(ps);
+    beep();


+public class Test {
+    public static void main (String[] args) {
+	System.loadLibrary("OCaml");
+	Test i = new Test();
+	String[] as = { "hello" };
+	i.caml_startup(as);
+	System.out.println("Hello world !!");
+    }
+    private native void caml_startup(String args[]);


+let _ = prerr_endline "hello world"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.