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.
On the next page of the wizard make sure that “Create module-info.java” is checked.
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.
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
JAAS login module using PAM
Compiling JDK classes with debug enabled
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 moreProxying requests with Jetty
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 moreApache commons-httpclient vs. self signed certificates
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 moreAutoboxing? not for me!
Log4j based logging in Tomcat 6 - Part 2
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 moreLog4j based logging in Tomcat 6
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 moreLog4j and logger additivity
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 …