Java Support in Octave

The trick I was using earlier to get Java support in Octave was merely a workaround. My mentor Michael told me that cross-compiling Octave with Java support was not working out of the box. Firstly, including Java support required us to get a local Windows installation of JDK. Only the Windows version of JDK had the file jvm.dll which was checked during configure. Linux version of java (OpenJDK) didn’t have that file. After some discussion, I came to know that jvm.dll is not required to build Octave with Java. Apparently the only files necessary to get Java support was jni.h and the platform dependent jni_md.h.

To remove jvm.dll checking, I used the following patch:

diff --git a/src/octave-2-no-jvm-check.patch b/src/octave-2-no-jvm-check.patch
new file mode 100644
--- /dev/null
+++ b/src/octave-2-no-jvm-check.patch
@@ -0,0 +1,18 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains patch to remove checking for jvm.dll during integration of Java support in Octave
+
+diff -r bb713af2e1d9 configure.ac
+--- a/configure.ac	Tue Jul 30 00:49:37 2013 -0400
++++ b/configure.ac	Thu Aug 01 02:57:25 2013 +0530
+@@ -2441,9 +2441,6 @@
+     darwin*)
+       jvmlib=libjvm.dylib
+     ;;
+-    mingw* | cygwin*)
+-      jvmlib=jvm.dll
+-    ;;
+     *)
+       jvmlib=libjvm.so
+     ;;

The process of exporting all missing symbols has now been added as a patch. So there is no need to make the change in the original package, get the sha1 checksum and update octave.mk.

Even though jvm.dll checking was removed, the compiler complained about missing jni_md.h file. OpenJDK had the file jni.h, but it was not enough to build Java enabled Octave. So Michael suggested something much better. He said that it should be possible to download the two header files and put them somewhere into the include directory of mxe-octve (like usr/i686-pc-mingw32/include/java/) and then make Octave to use them. I have pushed a changeset in my repo to do this. Now, one will be able to build Octave with Java enabled without having to hack the –with-java-homedir, –with-java-includedir, and –with-java-libdir options. The using of separate JNI headers during build is limited just to cross-compilation. For native builds, Octave would compile just like it did before. See the new src/octave.mk file here.

Leave a comment