Platform Independent Builds with Java

SAN FRANCISCO (08/25/2000) - Any large Java project may be developed, deployed, and maintained on multiple OS platforms over its entire lifecycle. A software project typically needs automated build/make scripts to compile, jar, and create the libraries and binary distributions.

While a project is under active development, you need to execute such build scripts quite frequently -- commonly on a daily or weekly basis. When an application has already been deployed in production (it is in maintenance mode), you need to execute the build scripts less frequently: when bug fixes or change requests have been addressed and revised distributions need to be released.

Since Java is a platform-independent language, it makes sense to avoid tying your build script or process to any particular OS, as far as possible. That would avoid hardships if the development platform were to change later.

IDE-independent build scripts

In the case of Java, the Java 2 Software Development Kit (SDK) Standard Edition is specification based (rather than implementation based) and covered by the Java 2 Standard Edition (J2SE) specification. The Java 2 SDK Standard Edition comprises the development tools and the runtime environment. Each release of the Java 2 SDK contains the compiler, a nonvisual debugger, class libraries, and other such development tools and utilities (including appletviewer, javadoc, jar, and so on). The runtime environment provides only a part of the platform necessary for running the programs so that the development tools are excluded. The Java 2 SDK is an elaborate and stable development environment that has been implemented and ported on all major OS platforms. Java IDEs typically use the SDK and provide additional features such as a "Java-aware" editor, support for visual debugging, graphical shortcuts to standard SDK tools, and so forth.

Although Java IDEs generally provide user interface-based support for build/make, it is recommended that build scripts for Java projects be IDE independent for you to expose and then eliminate any unwanted hidden IDE dependencies that may be present in the Java code.

Java build tools

Tools that provide such a platform-independent and automated build/make process include Make for Java (jmk) from the Free Software Foundation and Ant from the Jakarta Apache Project/Apache Software Foundation.

Make in Java

Make in Java (jmk) was inspired by and based on the Unix make utility, which has been around for quite some time. That utility evaluates a set of dependencies and then executes commands to ensure that a set of source and executable files are in a consistent state. If any inconsistency is detected, appropriate commands, as stipulated in the makefile, are executed. jmk is similar to that Unix utility, but it is written in Java and available under the Free Software Foundation's GNU license. Similar to the Unix make utility, jmk evaluates a set of dependencies stipulated in a "jmk" make file and then executes external commands that help maintain a set of source and executable files in a consistent state. jmk relies on the invocation of external commands/programs that have the same syntax across operating systems.

Examples of such programs include the javac compiler, the jar utility, and the javadoc utility.


Ant, from the Jakarta Apache Project, is another build tool that supports platform-independent builds. Ant is also written in Java, but it uses a different approach from that used by jmk. Ant provides Java classes that represent development and file management utilities and thus avoids dependency on external programs that must have the same syntax across OS platforms. At the same time, Ant provides the facility of using external commands as needed. Ant uses the more flexible XML-based build files.


Large Java projects may be built on multiple OS platforms over their entire project lifecycle. Therefore, a pristine, platform-independent build process is advantageous; it avoids any unnecessary association with the platform on which the program was originally built. The jmk utility from the Free Software Foundation and Ant from the Jakarta Apache Project are two build tools that support such a process.

About the author

Sanjay Mahapatra is a Sun Microsystems Inc.-certified programmer (Java 1.1), developer (Java 2), and architect (Java 2). He currently works for Cook Systems International, a consulting and solutions company.

Join the newsletter!

Error: Please check your email address.

More about ApacheApache Software FoundationFree Software FoundationSun Microsystems

Show Comments