[Fedora-packaging] Java -- how to use jni.h

Stepan Kasal skasal at redhat.com
Tue May 12 15:06:08 UTC 2009


Hello Andrew,

On Mon, May 11, 2009 at 09:43:07AM -0400, Andrew Overholt wrote:
> Sure, it would be great if you could post a patch to the wiki page it
> would help.

attached please find a first approximation; patch to Packaging:Java
wiki source.

Cheers,
	Stepan Kasal
-------------- next part --------------
Summary: Added subsection: How to build with jni.h generally

--- packaging.orig	2009-05-12 16:58:30.000000000 +0200
+++ packaging-java	2009-05-12 16:59:28.000000000 +0200
@@ -344,6 +344,22 @@
 {{Anchor|JNI}}
 == Packaging JAR files that use JNI ==
 
+=== Writing general spec file ===
+Keep in mind that your package should build under different flavors of Java.  In order to achieve this, you have to instruct the C preprocessor to search for header file in the include subdirectories under <code>/usr/lib/jvm/java</code>, which is a symlink maintained by the <code>alternatives</code> system.
+(Though file <code>jni.h</code> is
+in the default gcc include path when gcj is used, it is not so for openjdk.)
+
+If the package uses Autoconf-generated configure script, follow this template:
+<pre>
+BuildRequires: java-devel
+[...]
+%build
+for i in -I/usr/lib/jvm/java/include{,/linux}; do
+      java_inc="$java_inc $i"
+done
+%configure CPPFLAGS="$java_inc"
+</pre>
+
 === Applicability ===
 
 Java programs that wish to make calls into native libraries do so via the Java Native Interface (JNI).  A Java package uses JNI if it contains a .so


More information about the Fedora-packaging mailing list