DEV Community

Cover image for Let's revisit Java in 2019

Let's revisit Java in 2019

Sumit on October 19, 2019

It's been 6 years from now since Java 8 was released and people are still not able to digest the features of it, wasn’t Java 8 a fantastic update t...
Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

Java is hip again, indeed. The language has received great updates as well as the JVM (and there are several to chose from). However project jigsaws can be a pain in the ass du to errors like this:

cannot access class jdk.internal.misc.Unsafe

Or this one:

...because module java.base does not export jdk.internal.misc to unnamed module.

And then you have to find out which VM args to use. Is it "–illegal-access=permit"? Or "--add-exports java.base/jdk.internal.misc=ALL-UNNAMED". Or even "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"? That sucks.

But on the plus side there's jlink. With jlink it's possible to build Docker containers of less than 100MB that includes Alpine Linux, a stripped down JDK 11 and your app with all dependencies. That's really a big achievement and compensates for the trouble that the Java module system has caused.

Collapse
 
aussieguy profile image
Anthony Bruno

Nice article! The increased cadence of releases has allowed a lot of cool features to be added to Java. Even the smaller additions of List.of() and Map.of() has saved me heaps of time!

The new HttpClient is also a nice replacement for UrlConnection. I wrote an article about it here.

Collapse
 
tech_sam profile image
Sumit

These new changes and collection factory method really reduced lots of boilerplate, at least now I am feeling happy as a Java developer after so long 😉

Collapse
 
mustabelmo profile image
Mustapha Belmokhtar

thanks @sumit for the article.
In this example

Stream<String> stream = Stream.of("sam", "sumit", "jhon","nancy");
List<String> list = stream.dropWhile(name -> (name.charAt(0) == 'a'))
              .collect(Collectors.toList());

The drop-while conditon is name.charAt(0) == 's'.

Regards

Collapse
 
tech_sam profile image
Sumit

@mustapha , thanks for your valuable time to read and pointing out the mistake, fixed it :)

Collapse
 
brogrammerben profile image
Ben

Java 11 supports cgroups out of the box (came in Java 10) which are necessary for resource limits on containers, a handy feature in Kubernetes. Just another reason to upgrade to keep up with modern tech stacks.

Collapse
 
geoffreyarthaud profile image
Geoffrey Arthaud

Many Thanks for your article. I personnally like the strategy you suggest : you dev and push code in production with Java LTS release (Java 11 today) ; and you thoroughly test every following version (12 and 13 today) on your CI !

Collapse
 
fultonbrowne profile image
Fulton Browne

Great article, I have bean a java developer for 2 years and I didn't know about the var feature, thanks for mentioning it, it should save me some time.

Collapse
 
daviddalbusco profile image
David Dal Busco • Edited

Me neither I didn't knew about var.

In Javascript nowadays using var is kind of discouraged. It's kind of funny that in Java it's the contrary.

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

Well, but the reason is obvious, isn't it? A "var" has completely different implications in these 2 languages.

Thread Thread
 
daviddalbusco profile image
David Dal Busco

I did not say the opposite.

Collapse
 
prathamket profile image
prathamesh

Very well written.. but yeah there are some other dynamic programming languages available in market to overcome the underfloor stack. I have been using Java for long time on just putting my hands on python, I found python really easy and interesting. Yeah Java is generally faster and more efficient than Python coz it is compiled language.but python had really great libraries and most of the major libraries are available with free licences for commercial use.