13 Dec 2018

feedDZone Java Zone

Migrating Spring Boot Applications to the Latest Java Version (Java 11)

Recently, we started moving our applications from Java 8 to Java 11; this was after the announcement from Oracle that they will stop providing commercial support starting early 2019 for Java 8.

I would like to confine the scope of this topic as I will not be discussing, in detail, Java 11 and its features, but instead, I will try to provide a high-level explanation behind our migration to the latest version of Java and the steps involved in this transition.

13 Dec 2018 5:02pm GMT

Dropping Raw String Literals From JDK 12

It has been proposed that raw string literals (preview) be dropped from JDK 12 (which enters Rampdown Phase One on December 13). Brian Goetz has written a detailed description of the motivations for dropping this preview feature (JEP 326). There is also discussion on this on the Java subreddit.

In Goetz's explanation for the proposal to remove raw string literals preview functionality from JDK 12, he writes, "The Preview Feature mechanism is intended for features for which there is a high confidence that the feature is 'done,' and the likelihood that significant changes would be made before making the feature permanent is low." Goetz adds, "I am no longer convinced that we've yet got to the right set of tradeoffs between complexity and expressiveness, or that we've explored enough of the design space to be confident that the current design is the best we can do. By withdrawing, we can continue to refine the design, explore more options, and aim for a preview that actually meets the requirements of the Preview Feature process (JEP 12)."

13 Dec 2018 11:01am GMT

Java Annotated Monthly — December 2018

Happy winter/summer solstice and any associated festivals and holidays you may or may not celebrate! This month's annotated contains a mix of news and talks from various autumn conferences and some light reading to tide you over until the new year.

Java News

A lot of the news in this section came from Devoxx, Belgium, which seems to be the place to announce things after Oracle Code One, or re-iterate messages from that conference. All the talks from Devoxx were streamed and recorded, see the Tweet below for more details on just some of the presentations.

13 Dec 2018 8:01am GMT

JVM Advent Calendar: Comparing Kotlin Performance With Graal and C2

You may have heard of Graal, the new JIT compiler for the JVM written in Java. It has been available inside the JDK since Java 10, and in the future, it will probably become the standard of the JDK.

In the last year, I mostly worked with Kotlin, and as a personal project, I implemented a bot to play the game Go in Kotlin. You can find the source on GitHub.

13 Dec 2018 5:01am GMT

12 Dec 2018

feedDZone Java Zone

Java 8 Streams API: Laziness and Performance Optimization

We have had a quick overview of the Java 8 Streams API in our prevous post. We looked into the power and simplicity of the Java 8 Streams API, the Intermediate and the Terminal Operations over the streams, and different ways to build streams (e.g. from collections or numerical ranges, etc.). In continuation of the same discussion, in this post, we will move ahead with the streams and have a look at the most important property of Java 8 Streams - laziness. If you are new to the concept of Java 8 streams, please go back and read Understanding Java 8 Streams API.

Laziness Improves Performance?

This is a really tricky question. If the laziness is utilized in the correct manner, the answer is 'yes.' Consider you are on an online shopping site and you searched for a particular type of a product. Usually, most of the websites will show the matching products immediately and a 'loading more' message at the bottom. Finally, all of the search results will be loaded in parts, as described. The intent behind doing this is to keep the user interested by immediately showing him some of the results. While the user is browsing through the loaded products, the rest of the products are being loaded. This is because the site is delaying the complete loading of the entire product list. Consider, if the site does eager loading or early loading of all of the products, the response time would increase and the user might get distracted to something else.

12 Dec 2018 5:01pm GMT

How to Convert an Array to String in Java [Snippet]

Using Arrays.toString() Method

Arrays.toString() returns a string with the content of the input array. The new string created is a comma-delimited list of the array's elements, surrounded with square brackets ("[]"):

// Using Arrays.toString()
    public static String convertArrayToString(String[] strArray) {
        return Arrays.toString(strArray);
    }


12 Dec 2018 11:02am GMT

How to Solve Your Java Performance Problems (Part 2)

In the first part of this post, we explained the Performance Diagnostic Methodology (PDM) and how to use it. But, the proof of the pudding is in the eating, and therefore, it is now time to apply the methodology. Of course, the best proof would be to apply the methodology to a real world performance issue, but instead of waiting for that, we will try to simulate some performance issues and verify whether the methodology can work.

Testing Method

We will test the methodology by means of two cases:

12 Dec 2018 8:01am GMT

JVM Calendar: JDPR or Java Data Protection Recommendations

One major event that reverberated across the entire tech ecosystem was the 2018 introduction of GDPR, the General Data Protection Regulation for European Citizens. While it remains to be seen I this will or will not impact British citizens, it offers a positive opportunity for Java developers to take interest in three areas of security:

  1. Locating personally-identifiable information (PII) or other sensitive data in their applications.
  2. Using cryptography correctly, to properly protect this information and secure systems.
  3. Applying effective patch management of custom code, libraries, and JREs.

Locating PII and Sensitive Data

Java developers have a benefit of locating PII through static typing and clear APIs. As an example for developers writing POJOs, standardized method naming adopted by most of the community can reveal potential PII information like getAddress(), getName(), or getSomethingElseThatLooksLikePII(). Combing through method names, developers with moderate familiarity with PII goals can easily locate points of interest where PII bears sleep and identify potential leaks.

12 Dec 2018 5:01am GMT

11 Dec 2018

feedDZone Java Zone

How to Create an Array List in Java

To store dynamically-sized elements in Java, we used ArrayList. Whenever new elements are added to it, its increase their size automatically. ArrayList implements Java's List Interface and part of Java's Collection.

Because of their functionality and flexibility, it is widely used.

11 Dec 2018 9:01pm GMT

Spring Core Skills: Your First Spring Application [Video]

A lot of developers join a Spring project throughout its lifetime, not from the very beginning. But what minimal dependencies do you need to get started with Spring (5.x) ? How do you springify your existing application? What is Spring's Java Config and how does it work?

You'll find out in this practical and witty episode.

11 Dec 2018 5:01pm GMT

Zulu Gets Graphical With OpenJFX

When Java was first launched in 1995, the thing that made it really stand out was its ability to add animation to a web page (good ol' tumbling Duke). Thinking about how we interact with devices today makes that sound ridiculous, but for those of us old enough to remember this, it was something almost magical.

From there, as we know, Java took the world of programming by storm and is still consistently either number one or two in the most popular programming language surveys like TIOBE and Redmonk.

11 Dec 2018 11:01am GMT

Using Java Flight Recorder With OpenJDK 11

Java Flight Recorder (JFR) used to be a commercial add-on of the Oracle JDK. As it's been open sourced recently along with Java Mission Control, everyone using OpenJDK 11 can now troubleshoot their Java apps with this excellent tool for free of charge. JFR, being a proprietary solution formerly, might be lesser known for those relying on previous versions of OpenJDK. Therefore, I thought it was worth writing a fresh post on using JFR with OpenJDK 11.

Overview

1.1. About Java Flight Recorder

JFR is a profiling tool used to gather diagnostics and profiling data from a running Java application. It's performance overhead is negligible and that's usually below 1 percent. For short running apps, this overhead might be above that because JFR requires some warm-up time on the start.

11 Dec 2018 8:01am GMT

JVM Advent Calendar: Docker and the JVM

Even though Docker was a 2016 thing, it is still relevant today. It is the foundation of Kubernetes, the most popular orchestration platform and go-to solution for cloud deployment.

Docker is the defacto standard solution to containerize applications/(micro)services. If you run Java application you need to beaware of a few gotchas and tricks. If you don't this post should still help you.

11 Dec 2018 5:01am GMT

10 Dec 2018

feedDZone Java Zone

How to Build OpenJFX 8 on Windows From Source

So you've heard the news. Oracle shook up the world and changed the support roadmap, release cycle, and other things for Java and related technologies. However, your business' JavaFX application(s) (and their dependencies) run on Oracle JDK 8. You like stability because if you don't, your business software might fail, costing you money or worse - putting you out of business and/or in debt.

So what does this mean for business consumers of Oracle JDK/JavaFX 8? Two things:

10 Dec 2018 5:02pm GMT

Java Convert Map to Array [Snippet]

Let's write a Java program that converts Map values to the String array.

Convert Map Values to Array Example

package net.javaguides.corejava;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class MapToArrayExample {
    public String[] mapValuesToArray(Map < Integer, String > sourceMap) {
        Collection < String > values = sourceMap.values();
        String[] targetArray = values.toArray(new String[values.size()]);
        return targetArray;
    }

    public static void main(String[] args) {

        MapToArrayExample mapToArrayExample = new MapToArrayExample();
        Map < Integer, String > sourceMap = new HashMap < > ();
        sourceMap.put(100, "ABC");
        sourceMap.put(101, "PQR");
        sourceMap.put(102, "XYZ");
        String[] targetArray = mapToArrayExample.mapValuesToArray(sourceMap);
        System.out.println(Arrays.toString(targetArray));
    }
}


10 Dec 2018 11:01am GMT

The JDKs: Which One to Use?

Recently (or not so much), Oracle announced that it will change the way Java evolves, adopting the "Release Train" to launch new versions. In addition, it has changed the way support for the versions will be offered, providing only support for LTS versions. The community made up of the Java Champions also spoke about it, explaining the changes in detail here.

However, along with this news, how are JDK builds available? Will they be free or paid? Before answering this, it's important to understand what a "valid" JDK for distribution actually means. In practical terms, there is only one set of source code for the JDK. The source code is hosted here. Anyone can pick up this source code, produce a build, and post it to a URL. However, there is a separate certification process that must be used to ensure that construction is valid. Certification is performed by the Java Community Process (JCP), which provides a Technology Compatibility Kit (TCK). If an organization produces an OpenJDK build that complies with the entirely TCK, this build may be described as "compatible with Java SE".

10 Dec 2018 8:01am GMT

10 Nov 2011

feedPlanetJava

OSDir.com - Java: Red Hat's top secret Java Killer/Successor: The Ceylon Project

From the Ceylon dept.:

Gavin King of Red Hat/Hibernate/Seam fame recently unveiled the top secret project that he has been working on over the past two years, a new language and SDK designed to replace Java in the enterprise. The project came out of hiding without much fanfare or publicity at QCon Beijing in a keynote titled "The Ceylon Project - the next generation of Java language?".

10 Nov 2011 6:01am GMT

OSDir.com - Java: Oracle Introduces New Java Specification Requests to Evolve Java Community Process

From the Yet Another dept.:

To further its commitment to the Java Community Process (JCP), Oracle has submitted the first of two Java Specification Requests (JSRs) to update and revitalize the JCP.

10 Nov 2011 6:01am GMT

OSDir.com - Java: No copied Java code or weapons of mass destruction found in Android

From the Fact Checking dept.:

ZDNET: Sometimes the sheer wrongness of what is posted on the web leaves us speechless. Especially when it's picked up and repeated as gospel by otherwise reputable sites like Engadget. "Google copied Oracle's Java code, pasted in a new license, and shipped it," they reported this morning.



Sorry, but that just isn't true.

10 Nov 2011 6:01am GMT

OSDir.com - Java: Java SE 7 Released

From the Grande dept.:

Oracle today announced the availability of Java Platform, Standard Edition 7 (Java SE 7), the first release of the Java platform under Oracle stewardship.

10 Nov 2011 6:01am GMT

OSDir.com - Java: Java SE 7 Passes JCP

From the Jitters dept.:

The next edition of Java has been approved by a Java Community Process executive committee, but not without some acrimony.

10 Nov 2011 6:01am GMT

OSDir.com - Java: JDK 7 RC1 Released

From the JDK dept.:

After an initial round of testing we've declared build 147 to be the first Release Candidate of JDK 7.



There are only thirteen changes in this build. Over half of them are administrivial updates that don't affect the actual code; the remainder are true showstoppers, including several hard VM crashes and a JIT correctness bug identified by an Eclipse unit test.

10 Nov 2011 6:01am GMT

OSDir.com - Java: Google Files Sizzling Answer to Oracle's Amended Java Complaint

From the Counter dept.:

Google has filed its answer to Oracle's amended complaint and its memorandum opposing Oracle's Motion to Dismiss. And we find out why Google didn't just roll over and pay Oracle for a license. Oracle asked in its motion to dismiss that the counterclaims alleging that Oracle's patents are invalid be dismissed. So Google explains more thoroughly why it believes they are in fact invalid. First, Google asserts:



Each of the Patents-in-Suit is invalid under 35 U.S.C. § 101 because one or more claims are directed to abstract ideas or other non-statutory subject matter.

10 Nov 2011 6:01am GMT

OSDir.com - Java: Apache loses Java showdown vote to Oracle

From the Dis Harmony dept.:

The Apache Software Foundation - one of tech's most influential open-source groups - is closer to quitting Java's governing body after losing a stand-off vote against Oracle on Java.



The Reg has learned that with 75 per cent of qualifying Java Community Process (JCP) members having voted on whether to ratify Oracle's proposed roadmap for Java 7 and 8, Oracle's plan has been accepted.

10 Nov 2011 6:01am GMT

OSDir.com - Java: Apache Software Foundation Resigns from Java Community Process

From the So Long dept.:

The Apache Software Foundation has resigned its seat on the Java SE/EE Executive Committee. Apache has served on the EC for the past 10 years, winning the JCP "Member of the Year" award 4 times, and recently was ratified for another term with support from 95% of the voting community. Further, the project communities of the ASF, home to Apache Tomcat, Ant, Xerces, Geronimo, Velocity and nearly a 100 mainstay java components have implemented countless JSRs and serve on and contribute to many of the JCPs technical expert groups.



We'd like to provide some explanation to the community as to why we're taking this significant step.



The recent Java SE 7 vote was the last chance for the JCP EC to demonstrate that the EC has any intent to defend the JCP as an open specification process, and demonstrate that the letter and spirit of the law matter. To sum up the issues at stake in the vote, we believe that while continuing to fail to uphold their responsibilities under the JSPA, Oracle provided the EC with a Java SE 7 specification request and license that are self-contradictory, severely restrict distribution of independent implementations of the spec, and most importantly, prohibit the distribution of independent open source implementations of the spec. Oracle has refused to answer any reasonable and responsible questions from the EC regarding these problems.

10 Nov 2011 6:01am GMT

OSDir.com - Java: Apache Discontinues Independent Java Implementation 'Harmony'

From the DisHarmony dept.:

After the resignation of Apache from the Java SE/EE Executive Committee, the time has now come for Harmony to be added to the Apache Attic. Harmony was 'the project to produce an open source cleanroom implementation of Java.' An open vote was taken within the Project Management Committee, which resulted in a 20-2 majority to discontinue development.

10 Nov 2011 6:01am GMT

Javable: YourKit Java Profiler 7.0 released

The major update to YourKit Java Profiler has been released. Version 7.0 includes

10 Nov 2011 6:01am GMT

Javable: Sun phases out mobile Java

Sun will gradually phase out mobile Java (Java Micro Edition) and move respective services to Standard Edition. "We're trying to converge

10 Nov 2011 6:01am GMT

Javable: Google Android SDK is available

The development kit and API for Google mobile platform, Android, has been released.

10 Nov 2011 6:01am GMT

Javable: Consumer JRE Early Access

Sun has started an early access program to Java SE 6 Update N (formerly known as the "Consumer

10 Nov 2011 6:01am GMT

Javable: NetBeans 6.0 released

New version of pure Java IDE has been released, with support for many new

10 Nov 2011 6:01am GMT

Javable: Happy New Year!

We wish a Happy New Year to all our readers and contributers. Hope to see you all in 2008.

10 Nov 2011 6:01am GMT