July 24, 2013

Why repeat activities manually when you could spend much more time and effort to create a Java process library instead?

This is a question we've been asking ourselves lately. As our company and engineering team grows, we’ve found that different projects have somewhat similar needs when it comes to libraries. Whenever this happens and we think that the library can be useful for the rest of the Java world, we open-source it.

Download the Library on GitHub



http://xkcd.com/974/

So, without further ado let me introduce you to Yet Another Process Library for Java (similar to our YAZLJ). It is written in Java for Java and is meant to manage processes that you launch from your own programs.

Let me show you a quick example. In order to find out the version of the Java executable found in the path you would have the following line in your program.

new ProcessExecutor().command("java", "-version").execute();

Why We Made Yet Another Process Library for Java

You're probably thinking, why would I need yet another process library? I've already got the JRE standard API library and the Apache Commons Exec? Well, yeah but when you use them, and you use them heavily, you discover writing lots of helpers to get rid of the boiler plate. Maybe even extending them to get more out of them. This is what happened over here. I'll outline some of the features that the library provides on top of the other choices I mentioned.

Process Library for Java Features:

Improved handling of streams Reading/writing to streams Redirecting stderr to stdout

Improved handling of timeouts

Improved checking of exit codes

Improved API One liners for quite complex usecases One liners to get process output into a String Access to the Process object available Support for async processes ( Future )

Improved logging with SLF4J API

Support for multiple processes

Download Yet Another Process Library for Java

The project is hosted at GitHub, the CI is at Travis. The project page has tons of examples to get you started, the 1.4 release is available from Maven central so you should be all good to go. Take the library for a spin and let us know what you think in the comments section below, or ping me @toomasr :-)

Want to see the latest from our development team?

Check out our resources page for our upcoming and recorded webinars.

See Available Webinars