21 Oct 2019

feedDZone Java Zone

Constructor Value Vs. Observer in Java

Who wins in the battle between Constructor Values and the Observer? Well, it depends.

Who Belongs to Whom?

It is common to connect two components using constructor parameters. This procedure can be seen very clearly, for example, in the construction of graphic surfaces. Take the following source code:

public class SubView {
  private MainView mainView;
  public SubView(MainView mainView) {
    this.mainView = mainView;
  public void buttonClicked(String input) {

21 Oct 2019 12:28pm GMT

How to Configure Your Spring Boot Jetty Server With Maven [Video]

In the video below, we take a closer look at configuring the Jetty Server in Spring Boot using Maven. Let's get started!

Further Reading

[DZone Refcard] Core Jetty

21 Oct 2019 12:25pm GMT

Read Replicas and Spring Data Part 4: Configuring the Read Repository

Here's the next step for configuring your read repo!

Previously, we set up two EntityManagers in the same application - one for the reads and one for the writes. Now, it's time to create our read repository. Let's get started!

In case you missed it: Read Replicas and Spring Data, Part 1: Configuring the Database; Part 2: Configuring the Base Project; and Part 3: Configuring Two EntityManagers.

The read-only repository will use the secondary read-only EntityManager.

21 Oct 2019 12:23pm GMT

18 Oct 2019

feedDZone Java Zone

Writing About Java [Prompts]

Ever struggle with what to write? No worries, we've got you covered. Here's a list of Java prompts and article ideas to help cure even the worst cases of writer's block. So, take a moment, check out the prompts below, pick one (or more!), and get to writing.

Also, please feel free to comment on this post to bounce around ideas, ask questions, or share which prompt(s) you're working on.

18 Oct 2019 1:45pm GMT

14 Tips for Writing Spring MVC Controllers

Here are the best tips and tricks for writing Spring MVC Controllers.

In this article, I'm going to share with you some of the fundamental techniques and best practices for writing a controller class with the Spring MVC framework. Typically, in Spring MVC, we write a controller class to handle requests coming from the client.

Then, the controller invokes a business class to process business-related tasks, and then redirects the client to a logical view name, which is resolved by Spring's dispatcher servlet in order to render results or output. That completes a round trip of a typical request-response cycle.

18 Oct 2019 11:28am GMT

Spring MVC: HTTP Message Converter

Don't shoot the messenger (pigeons)!

Quite often, you need to provide users with the same data, but in different forms, like JSON, PDF, XLS, etc. If your application is Spring Framework-based, this task can be achieved using HTTP message converters.

HTTP message converters are applied when an HTTP request (or its parts) needs to be converted into type required for handler method argument (for more info, see Handler methods - method arguments), or when the value is returned by handler method needs to be converted somehow to create HTTP response (for more info, see Handler methods - Return values).

18 Oct 2019 11:28am GMT

Introducing Java Record

Introducing... Java Record!

The latest JEP 359 outlines a new Java feature that may/will be implemented in some future versions of Java. The JEP suggests having a new type of "class": record.

You may also like: Java Records: Making Bad Designs More Convenient

The sample in the JEP reads as follows:

18 Oct 2019 11:28am GMT

17 Oct 2019

feedDZone Java Zone

Optional Is the New Mandatory

Optional is mandatory.

Since the beginning of the "computer programming era," developers searched for a solution to one of the biggest mistakes ever made in computer science, the invention of the null reference. Since functional programming became mainstream, the solution to this problem surfaced, the use of the optional type. In this post, we analyze how this type is used in different programming languages, trying to understand the best practices to apply in each situation.

You may also like: 26 Reasons Why Using Optional Correctly Is Not Optional

Returning the Nothing

Let's start with a concrete example. Think about a repository that manages users. One classic method of such type is the method def findById(id: String): User, whatever an id could be. This method returns the user that has the given id, or nothing if no such user exists in your persistence layer.

17 Oct 2019 4:23pm GMT

The 2019 Java Developer Roadmap

What on the roadmap for Java developers?

One of the requests I received from many of my readers was to create a Java developer roadmap. Since Java is my area of expertise, it wasn't a problem to create a roadmap, but it took slightly longer for me to create one because of my limited free time. Anyway, I am finally ready to share my Java developer roadmap with you all.

This roadmap contains an unobstructed path on how to become a Java expert, answering burning questions like: Which technologies should a Java developer learn? What tools make you a better Java developer? And lastly, which frameworks must a Java developer absolutely learn?

17 Oct 2019 2:40pm GMT

Spring Boot for Apache Geode and Pivotal GemFire Released (Ver. 1.2.0)


Released toward the end of August 2019, Spring Boot for Apache Geode and Pivotal GemFire (SBDG) is now available. Set to align SBDG onto the latest GemFire/Geode and Spring bits, this release includes a variety of new features the blend both convention and choice to help you customize the behavior of your Spring applications. It's a great place to start when building Apache Geode or Pivotal GemFire applications with Spring.

You may also like: [DZone Refcard] Core Spring Data

Focused on helping developers stay productive and solve important, relevant problems, this update includes new dependencies, support for caching use cases and patterns, hybrid cloud deployments, and more. With an easy transition from previous versions of SBDG, the focus on developer productivity makes it easy for you to get up and running quickly and reliably with the latest version.

17 Oct 2019 2:31pm GMT

Java Concurrency, Part 3: Synchronization With Intrinsic Locks

Learn more about Java synchronization with intrinsic locks.

After learning how to create threads and manipulate them, it's time to go to one of the most important things: synchronization. Synchronization is a way to make some code thread-safe. Code that can be accessed by multiple threads must be made thread-safe. Thread-safe describes some code that can be called from multiple threads without corrupting the state of the object or simply doing the thing that the code must do in the right order.

Disclaimer: This article was originally published in August 2010. The code shown below has been updated and tested in Java 12.

17 Oct 2019 1:52pm GMT

This Week in Spring: SpringOne Platform Wrap-Up, Tutorials, and More

There are lots happening this week in Spring!

Hi, Spring fans! WHEW! What a week! Last week was the insane SpringOne Platform 2019 event, from which I am still recovering! Then I flew home, hosted my Spring team member, Micrometer lead, and friend, Tommy Ludwig in San Francisco, and prepared to fly out for meetings and user group appearances on Monday (in Stuttgart, Germany) and Tuesday (in Amsterdam).

However, I was prepared and getting into the Uber on my way to the San Francisco airport when I got a call from my brother saying my 81-year-old dad wasn't doing well (thanks to everyone for the well wishes!) and was rushed to the hospital. I had to, regretfully, cancel my live appearances in those countries. I am SO sorry for those I disappointed. I was very happy to be able to do a few of those meetings remotely. Thanks to everyone who indulged me and supported me as I flew to Los Angeles to be with my father.

17 Oct 2019 1:02pm GMT

Generating a JAX-WS Client JAR From WSDL URL Using PowerShell

Don't underestimate the power of PowerShell.

Sometimes, I like to get to the point directly rather than read an entire article. So if you are short on time, you may want to skip to the final step where you just have to copy the code, save it as a PowerShell script file, and run it with PowerShell.

However, if you are in the mood to do a little reading, then let's begin.

17 Oct 2019 1:02pm GMT

16 Oct 2019

feedDZone Java Zone

A Use Case With JavaCC [Snippet]

Let's say you have the following file:

sfsfasdfsdf  dfdsfsdfs f 
 Barcelona, Total SCORE 8 (4+4). 
          having 100% success rate. 

sfsdfsdfdf sfasdfum 34749n afsf

 Barcelona, Total SCORE 2 (6-4). 
          having 100% success rate.    

16 Oct 2019 11:39am GMT

Java Concurrency, Part 2: Manipulating Threads

After seeing how to create Threads, this article will explore what we can do to manipulate Threads in our Java applications.

Please keep in mind all code demonstrated in this article has been tested and debugged in Java 12.

16 Oct 2019 11:23am GMT

Become a Master of Java Streams, Part 2: Intermediate Operations

Want to become a Java Streams Master?

Just like a magic wand, an Intermediate operation transforms a Stream into another Stream. These operations can be combined in endless ways to perform anything from simple to highly complex tasks in a readable and efficient manner.

This article is the second out of five, complemented by a GitHub repository, containing instructions and exercises to each unit.

16 Oct 2019 11:22am GMT

10 Nov 2011


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