Recently, Oracle released a new Java version, Java 8. According to Brian Goetz (Java Language Architect), it has been in development for over 4 years and it’s development started before the launch of the former version, Java 7 . This is the release with the most added features since the first Java version.
It all seems great, but can I install it and run my old Java projects on it?
There are some changes in base Java objects and interfaces, such as the Collection interface. This interface contains a new method stream(). So, let’s imagine that you have an implementation of this interface in your program. What you would usually expect is that your code would not compile anymore, as you don’t have the stream() method implemented.
Java 8 introduces also a new concept, the default methods. Default methods are used to define a default action to implementations which don’t implement that method. Each new method in the base Java objects and interfaces from this release implement a default action, which allows the backward compatibility of older Java projects.
With that in mind, it should be possible to run older Java projects with the new Java release. But, you won’t be able to take the most out of it without refactoring your code.
So, what’s next?
I am starting now digging into Java 8. I expect to publish from time to time some short introductions to the novelties, with a touch of what I experience, together with some useful examples.
So, stay tuned and share your experiences!
- R. Warburton, Java 8 Lambdas: Pragmatic Functional Programming, O’Reilly Media, 2014