Using Java in 2022

Booglejr | 01/08/2022
Using Java in 2022

NOTE: Bare in mind the stuff being discussed here is absolutely by no means legal advice.

Some might be convinced that Java is outdated or dead. But these people couldn't be more wrong. Java absolutely still fits into modern infrastructures just in a different capacity. So here's a list of just a few points I think are crucially relevant to either newcomers or returning users.

Don't use Oracle's JDK just use OpenJDK!

So let's get right into it. Java 8 is still used everywhere, it's fairly absurd considering how old Java 8 is these days. But a lot of stuff happened between Java 8 and 11 and some of these things cause hesitation when people think of migrating. We'll go ahead and get started with JDK licensing shift. When Oracle released Java 11 they shifted their licensing strategy to require all non-personal projects to need a license. At the same time they moved the non vendor supported open-source version under the OpenJDK project.

There's a lot of OpenJDK variants!

Yes. Yes there are. With most them you'll probably never know the difference. A lot people use AdoptOpenJDK and I would recommend that one if you don't know which one to go with because they offer installers.

How does one even start a new Java project?

In my personal experience this is really frustrating. It seems like no one can just tell you how to start a simple Java project and it's absurd. We're 20 years past the age when it's okay to just keep all your dependencies in a folder on your desktop and hope you don't lose them. Simply put, people expect dependency management and I wholeheartedly agree. And I can say without a doubt you should use Gradle. Please use Gradle. Maven is very confusing for a newcomer and Ant doesn't feel much more sophisticated than a makefile.

Distributing Java applications in 2022 - Server

As the web moves towards a microservices architecture, containerization has become standard. Installing a full JVM in every container will eat up a lot of space very quickly and is simply impractical especially when an average Java application will probably use only a small percentage of the standard JRE library. In Java 9, at tool known as JLink was introduced and this command-line tool allows developers to produce a slimmed down version of the JVM containing only libraries they specify which can then be installed into the container rather than the entire JVM.

Distributing Java applications in 2022 - Desktops

Expecting users to have a JVM on their computer is ridiculous. People despise that little applet that tells them they need to update it and don't want to know Java is on their computer. Simply put Java has gone the way of Adobe Flashplayer. That's why in Java 16, JPackage was introduced. JPackage produces a JAR file for your code and and then executes JLink to slim down the JVM just for your code. FInally it packages this all together produces an installer for your respective system. It can even configure the executable icon that will be associated with the installed application. This absolutely also has implications in the server realm as well, in my opinion it simplifies the work you have to do slimming down the JVM if nothing else, but it is up to you.

So about Gradle?

I personally thought when I heard it was scripted with Groovy, that I would quickly become frustrated and not want anything to do with this software but Gradle is actually really easy to use. And for the most part it does a lot of work for you. Tasks are already defined but you can override, modify, and add to all of them. I absolutely believe that any developer should know how to accomplish a task without an IDE before using an IDE simply because when it inevitably breaks the software can be fixed and possibly optimized. Gradle fits right in line with this philosophy by making the work easy but it still doesn't take complicated steps that are impossible to follow. It feels a lot like npm or cargo if you've ever had the pleasure of using either of those project managers.

Which Java version should I use?

Ideally, one should stick the latest LTS, 17, but if not that then go with 11 the other still-supported LTS version. 

And JavaFX is gone now???

Gone but never dead. As of Java 9, JavaFX's inclusion into the main JVM libraries was simply discontinued. The project lives on under the OpenJFX project which offers JAR files and links to include javafx as a dependency in Gradle or Maven. I personally love JavaFX and highly recommend it. It is themable, has more mobile support, and looks way better than Swing.

Anything Else

That's it. I promise. I hope that this helped to orient you on your journey to discover or rediscover Java. I personally believe that JPackage is huge for the Java community and we may see more projects using Java again as a result. As always thanks for reading. If you like this article then please share. I also appreciate comments as well! Have a great day everyone. :)





RockStar Redneck

said on 01-09-2022:

I’ve always heard that Java is slow and to avoid it. At the same time Java is everywhere. So, either it is not slow or it’s ease of deployment across platforms outweighs any perceptible speed issues vs other development languages and toolsets.