WAR files vs. Java apps with embedded servers

Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container. The traditional way to package these apps for distribution is to bundle them as a WAR file. This is nothing more than a ZIP archive with a standard directory layout, containing all of libraries and application-level dependencies needed at runtime. This format is mostly interoperable, and can be deployed to whichever server container you like, Tomcat or Jetty, JBoss or GlassFish, etc. [Read More]

How to install Oracle’s Java on Ubuntu the easy way

Developers on Ubuntu are accustomed to seeing at least two flavors of Java. OpenJDK is an open-source build of the Java runtime and compiler. The Oracle JDK is built upon this, but adds some closed-source components. In theory, OpenJDK is the official reference implementation of Java 7, and should be perfectly fine for all your needs. In practice, it is still known for having issues with common app servers and frameworks. [Read More]

INI files for easy multi-environment config in Java

Almost all applications need to run in multiple environments. If nothing else, they are tested on a developer’s workstation before deployment to a production box. There can be QA and UAT environments in between, and there might even be more than one production target. At runtime, applications usually need environment-specific info such as which database to use, credentials, etc. Large-scale apps normally manage this with a dependency-injection framework like Spring. The typical “cloud” host approach is to use environment variables. [Read More]

Injecting JavaScript into Ant builds

Background Recently I’ve been working on an implementation of hybris, a Java e-commerce package whose build system is based on Ant. The Maven Ant Tasks plugin is available for importing dependencies, but I wasn’t happy with the default tasks that wrap this plugin. They make no attempt to purge old dependencies that have been removed from the POM. The build script keeps your Eclipse projects up to date with most changes, but does not update classpath settings when dependencies change. [Read More]

“Batteries included” distribution using Maven shaded JAR’s

JAR’s that act like WAR’s? One of the nice things about web application development on the JVM is the WAR file format. With a WAR, libraries and other dependencies can be neatly packaged up with your code into a single file… ready for deployment. You can deploy multiple applications to the same server, and each one basically gets its own clean and isolated classpath(*). (*) Okay, you can still run into issues with the servlet engine’s common classpath. [Read More]