About Richard Warburton

Richard is a Principle Software Engineer at jClarity, interested in deep dive performance issues and compiler verification, Adopt-aJSR, Adopt OpenJDK and the LJC. He holds a PhD from the University of Warwick and lives in London.

Testing Java 8 in 3 Easy Steps

tl;dr Use your CI Setup to test Java 8.

The upcoming Java 8 release promises a bunch of new feature for Java developers, but there’s always a risk when upgrading that your code will break. We all remember that when Java 7 shipped it had a series of quite severe bugs.

Of course we can all help with avoiding the same issue cropping up in Java 8. The approach I’m going to cover today is using your existing Continuous Integration to run your tests on Java 8. If you don’t have a continuous integration server or tests go to jail, don’t pass go and don’t collect £200. I’m going to be using the open source hawkshaw memory shaper as an example of how to do this with a maven project.

1. Install JDK 8 on your CI Server

You can download an early access release of Java 8 from https://jdk8.java.net/download.html. You then have to install this as you would any Java release on your Continuous Integration Server itself.

You also need to add your new JDK 8 install to jenkins so its knows to look for the JDK. From the main screen go to Manage Jenkins and Configure System. You now need to look for the JDK Install section, untick install automatically and add the name and path.


2. Setup a Jenkins Multi-Build

You can setup another Jenkins Job for your existing project, but this has the downside that if you want to test on several JDKs and have several Projects you end with a lot of Jenkins Jobs to manage. If you’ve only got one job its a good solution though.

What I prefer to do is have a multi-build configuration so that the whole build can be failed by any JDK version. The first step is to create a new multi-build Jenkins Job.


As well as the normal setup of your Jenkins Job, you need to go to the Configuration Matrix section of the Job’s configuration and click add axis then select JDK. You can now tick the boxes that apply to the JDKs you want to use. Here I’ve selected a JDK 7 build a JDK 8 build.


You might also need to disable plugins which don’t work under Java 8, such as Jacoco.

3. Report Bugs

You can now run your builds and see whether they pass or fail under different Java versions, in my example build it passes under Java 7, but fails under Java 8:


At this point you need to figure out why your tests failed. Perhaps it was a bug in your code, in which case you can fix it now and have confidence that your application will work when Java 8 is released. Perhaps it was a Java 8 bug: in which case report it on the issue tracker or email the appropriate openjdk mailing list. You can also email adopt-openjdk@googlegroups.com if you want help with this. Please also email us if you’re successful – its great to hear feedback.

Reference: Testing Java 8 in 3 Easy Steps from our JCG partner Richard Warburton at the Insightful Logic blog.
Related Whitepaper:

Bulletproof Java Code: A Practical Strategy for Developing Functional, Reliable, and Secure Java Code

Use Java? If you do, you know that Java software can be used to drive application logic of Web services or Web applications. Perhaps you use it for desktop applications? Or, embedded devices? Whatever your use of Java code, functional errors are the enemy!

To combat this enemy, your team might already perform functional testing. Even so, you're taking significant risks if you have not yet implemented a comprehensive team-wide quality management strategy. Such a strategy alleviates reliability, security, and performance problems to ensure that your code is free of functionality errors.Read this article to learn about this simple four-step strategy that is proven to make Java code more reliable, more secure, and easier to maintain.

Get it Now!  

Leave a Reply

9 × two =

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books