I use the Eclipse IDE as my daily driver for development. For a long time I have ignored the Java Platform Module System (JPMS) which was introduced in Java 9 and I’m still ignoring it today. If you want a proper module system simply use the better one that has existed for many, many years.

One point I’ve always put forward when arguing against the use of JPMS is that there is no way to create a simple project in Eclipse that uses the JPMS and has unit tests as part of the same project - much like the project setup that Maven uses. Only today I found out that this is indeed possible if you know how to configure your project and hack your way with the module system.

Let’s start by creating a plain Java project in Eclipse. Make sure you have a JDK configured that supports JPMS and create separate output folders for sources and class files. Eclipse new project wizard, first step

On the next page of the wizard make sure that “Create module-info.java” is checked.

Eclipse new project wizard, second step

When you hit Finish Eclipse will ask you for the module name of the project. Give your module a friendly name and start hacking away at your sources. Rather sooner than later you’ll get to the point where you want to add tests for your code. Add a new source folder that will contain your tests. Configure the source folder for your tests to generate its class files into a different folder and make sure you trigger Contains tests sources.

Eclipse new project wizard, second step

In the Libraries tab add the JUnit library to Classpath section, not to the Modulepath section. This hack enables the JUnit classes to be found for compiling and running the unit tests. But you’re not required to put the JUnit module into module-info.java, leaking the JUnit dependency out into the module path.


SLF4J’s SimpleLogger

05.01.2017 by Dirk Olmes

I use the SLF4J API as the default logging facade in all my projects. SLF4J’s simple logger comes in handy when you don’t need a fully fledged logging framework. The SimpleLogger is despite its name quite configurable - if you know where to find the documentation: it’s in …

read more

JAAS login module using PAM

23.12.2014 by Dirk Olmes

I recently had a look into JAAS for a customer project. The API is not 100% straightforward due to its design goal of hiding implementation specifics but I guess that’s the price you have to pay when specifying a generic API.

The JAAS guide talks about JAAS’s similarity …

read more

Compiling JDK classes with debug enabled

21.12.2014 by Dirk Olmes

I recently had to poke around with the JAAS classes in the JDK and wanted to step through with a debugger. But the JDK ships with a rt.jar that’s not compiled with debugging symbols enabled. Thus, debugging into the JDK sources is not much of a success.

Some …

read more

Proxying requests with Jetty

24.01.2014 by Dirk Olmes

At work we develop a web based software for the automotive industry. On the server side we embed Jetty as HTTP server and Servlet engine. It’s easy to configure in code and performs very well.

Recently, we had to integrate a third party solution which comes as a virtual …

read more

Apache commons-httpclient vs. self signed certificates

03.10.2013 by Dirk Olmes

Recently I tried to retrieve HTML pages from a host that was using self signed HTTPS certificates. I used the excellent Apache commons httpclient for the job. Their tutorial is quite extensive and even gives examples about some customizations that can be made in the context of SSL. But being …

read more

Autoboxing? not for me!

16.09.2011 by Dirk Olmes

Autoboxing appeared first with JDK5 and lots of people go crazy about it. At first look it’s a nice feature but the more you play with it the more I’m coming to the conclusion that the autoboxing implementation just sucks.

I will not rant about autoboxing pitfalls that …

read more

Log4j based logging in Tomcat 6 - Part 2

15.06.2008 by Dirk Olmes

In my previous experiment I got Tomcat to log through commons-logging by following the Tomcat instructions.

While this works well for webapps that use commons-logging or log4j directly, webapps using JDK logging (e.g. Hudson) still clutter catalina.out. I remembered an approach that Holger was researching earlier: replace the …

read more

Log4j based logging in Tomcat 6

14.06.2008 by Dirk Olmes

My favourite annoyance in Tomcat is its logging to the ever-growing, never-rotated catalina.out.

The Tomcat logging setup instructions already contain a description what to do to make Tomcat log through log4. This is definitely a step in the right direction. Tomcat’s logging is properly separated from each webapp …

read more

Log4j and logger additivity

18.02.2008 by Dirk Olmes

Sometimes you want to write more than one logfile using logj4. This is possible by defining multiple appenders and specifying an appender for a certain logger like this:

log4j.appender.A1=org.apache.log4j.ConsoleAppender
....
log4j.appender.A2=org.apache.log4j.FileAppender
....

log4j.rootLogger=DEBUG, A1
log4j.logger.foo=DEBUG …
read more