So far, we've been using examples of building C and C++ programs to demonstrate the features of SCons. SCons also supports building Java programs, but Java builds are handled slightly differently, which reflects the ways in which the Java compiler and tools build programs differently than other languages' tool chains.
The basic activity when programming in Java,
of course, is to take one or more .java files
containing Java source code
and to call the Java compiler
to turn them into one or more
In SCons, you do this
by giving the
a target directory in which
to put the .class files,
and a source directory that contains
the .java files:
If the src directory contains three .java source files, then running SCons might look like this:
% scons -Q javac -d classes -sourcepath src src/Example1.java src/Example2.java src/Example3.java
SCons will actually search the src directory tree for all of the .java files. The Java compiler will then create the necessary class files in the classes subdirectory, based on the class names found in the .java files.