Featured Whitepapers
Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Benefit from platform-independent builds

Automate your build process with jmk or Ant

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
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.

About the author

Sanjay Mahapatra is a Sun-certified programmer (Java 1.1), developer (Java 2), and architect (Java 2). He currently works for Cook Systems International, a consulting and solutions company.
  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources