It feels like just yesterday we were getting comfortable with Java 10, and already Java 11 has arrived. But this isn't just another incremental update; Java 11 marks a significant shift, especially with Oracle's revamped support model and the move to a six-month release cycle. For developers, understanding these changes is key.
One of the biggest talking points around Java 11 is its support model. It's the second Long-Term Support (LTS) release after Java 8, which is great news for stability. However, Oracle JDK is no longer free for commercial use. This means if you're using Oracle JDK in a production environment, you'll likely need to purchase a license. Java 10 was the last free Oracle JDK for commercial use, and Oracle has ended support for Java 8 from January 2019, meaning no more patches or security updates unless you pay. Oracle won't be offering free LTS for any single Java version post-Java 11.
So, does this mean you have to pay for Java from now on? Not necessarily. You can still download and use OpenJDK builds from various providers like AdoptOpenJDK, Azul, IBM, and Red Hat. My take? Unless you're a large enterprise with a budget for dedicated support, sticking with OpenJDK and upgrading every six months (or when a new LTS arrives) is a perfectly viable path. Just be aware that if you choose to stay on a free version after its support ends, you might miss out on crucial security updates.
Now, let's dive into what Java 11 actually brings to the table for us developers. Oracle has been busy, and several Java Enhancement Proposals (JEPs) have introduced some really handy features.
Running Java Files with a Single Command
Remember the days of needing javac to compile before you could run? Well, JEP 330 has changed that. You can now run your .java files directly using the java command, and it handles the compilation implicitly. It's a small change, but it streamlines the development workflow quite nicely.
Handy New String Methods
The String class has received some useful additions. You've got:
isBlank(): This method returnstrueif the string is empty or contains only whitespace characters. It's a cleaner way to check for blank strings than the olds.trim().isEmpty().lines(): This one returns aStream<String>of lines from the string, split by line terminators. It makes processing multi-line strings much more straightforward.strip(),stripLeading(),stripTrailing(): These are Unicode-aware versions oftrim(),trim()andtrim(), respectively. They're more robust in handling various whitespace characters, which is a welcome improvement.
JEP 321: HTTP Client
This is a big one. Java 11 includes a fully featured HTTP client API, which is now a standard part of the JDK. It supports HTTP/1.1 and HTTP/2, handles asynchronous requests, and offers a much more modern and flexible way to interact with web services compared to the older HttpURLConnection.
JEP 328: Flight Recorder
For those deep into performance tuning and diagnostics, JEP 328 introduces Java Flight Recorder (JFR) as an open-source tool. It's a low-overhead profiling and event collection framework that can help pinpoint performance issues and understand application behavior in production environments. This was previously a commercial feature, so its inclusion in the open-source JDK is a significant win.
Java 11 also brings other enhancements like var for lambda parameters (JEP 323), allowing you to use local-variable type inference within lambda expressions, and nested-based access control (JEP 181), which refines how inner classes access members of their enclosing classes. And for those wondering about JavaFX, it's now a separate module, no longer bundled directly with the JDK, giving it its own release cycle.
Overall, Java 11 is more than just an update; it's a step towards a more agile and modern Java ecosystem. While the licensing changes require attention, the new features offer tangible benefits for developers looking to write cleaner, more efficient, and more robust code.
