3 SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
4 SPDX-License-Identifier: MIT
5 SPDX-FileType: DOCUMENTATION
7 This file is processed by the bin/SConsDoc.py module.
11 <!ENTITY % scons SYSTEM '../../doc/scons.mod'>
13 <!ENTITY % builders-mod SYSTEM '../../doc/generated/builders.mod'>
15 <!ENTITY % functions-mod SYSTEM '../../doc/generated/functions.mod'>
17 <!ENTITY % tools-mod SYSTEM '../../doc/generated/tools.mod'>
19 <!ENTITY % variables-mod SYSTEM '../../doc/generated/variables.mod'>
23 <sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
24 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25 xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
30 Sets construction variables for the &javah; tool.
35 <item>JAVAHFLAGS</item>
37 <item>JAVACLASSSUFFIX</item>
40 <item>JAVAHCOMSTR</item>
41 <item>JAVACLASSPATH</item>
45 <builder name="JavaH">
48 Builds C header and source files for
49 implementing Java native methods.
50 The target can be either a directory
51 in which the header files will be written,
52 or a header file name which
53 will contain all of the definitions.
54 The source can be the names of <filename>.class</filename> files,
55 the names of <filename>.java</filename> files
56 to be compiled into <filename>.class</filename> files
57 by calling the &b-link-Java; builder method,
58 or the objects returned from the
64 If the construction variable
65 &cv-link-JAVACLASSDIR;
66 is set, either in the environment
69 builder method itself,
70 then the value of the variable
71 will be stripped from the
72 beginning of any <filename>.class</filename> file names.
80 # builds java_native.h
81 classes = env.Java(target="classdir", source="src")
82 env.JavaH(target="java_native.h", source=classes)
84 # builds include/package_foo.h and include/package_bar.h
85 env.JavaH(target="include", source=["package/foo.class", "package/bar.class"])
87 # builds export/foo.h and export/bar.h
90 source=["classes/foo.class", "classes/bar.class"],
91 JAVACLASSDIR="classes",
97 Java versions starting with 10.0 no longer use the
98 <command>javah</command> command for generating JNI
99 headers/sources, and indeed have removed the command entirely
100 (see Java Enhancement Proposal
101 <ulink url="https:openjdk.java.net/jeps/313">JEP 313</ulink>),
102 making this tool harder to use for that purpose.
103 &SCons; may autodiscover a <command>javah</command>
104 belonging to an older release if there are multiple Java
105 versions on the system, which will lead to incorrect results.
106 To use with a newer Java, override the default values of &cv-link-JAVAH;
107 (to contain the path to the <command>javac</command>)
108 and &cv-link-JAVAHFLAGS; (to contain at least a <option>-h</option>
109 flag) and note that generating headers with
110 <command>javac</command> requires supplying source
111 <filename>.java</filename> files only,
112 not <filename>.class</filename> files.
121 The Java generator for C header and stub files.
126 <cvar name="JAVAHCOM">
129 The command line used to generate C header and stub files
131 Any options specified in the &cv-link-JAVAHFLAGS; construction variable
132 are included on this command line.
137 <cvar name="JAVAHCOMSTR">
140 The string displayed when C header and stub files
141 are generated from Java classes.
142 If this is not set, then &cv-link-JAVAHCOM; (the command line) is displayed.
146 env = Environment(JAVAHCOMSTR="Generating header/stub file(s) $TARGETS from $SOURCES")
151 <cvar name="JAVAHFLAGS">
154 General options passed to the C header and stub file generator