Automake provides some minimal support for Java bytecode compilation with
JAVA primary (in addition to the support for compiling Java to
native machine code; see Java Support with gcj). Note however that
the interface and most features described here are deprecated; the
next automake release will strive to provide a better and cleaner
interface, which however won't be backward-compatible; the present
interface will probably be removed altogether in future automake releases
(1.13 or later), so don't use it in new code.
Any .java files listed in a
_JAVA variable will be
JAVAC at build time. By default, .java
files are not included in the distribution, you should use the
dist_ prefix to distribute them.
Here is a typical setup for distributing .java files and installing the .class files resulting from their compilation.
javadir = $(datadir)/java dist_java_JAVA = a.java b.java ...
Currently Automake enforces the restriction that only one
primary can be used in a given Makefile.am. The reason for this
restriction is that, in general, it isn't possible to know which
.class files were generated from which .java files, so
it would be impossible to know which files to install where. For
instance, a .java file can define multiple classes; the resulting
.class file names cannot be predicted without parsing the
There are a few variables that are used when compiling Java sources:
JAVACFLAGS, should be used when it is necessary to put Java compiler flags into Makefile.am.
javac. It defaults to ‘$(top_builddir)’.
javaccommand line. (In the future we will probably handle class path setting differently.)