New to Java? Here Are Some Resources

In this tweet, I was asked if I had a list of resources for developers who are new to Java. I didn't at the time, but I've spent some time researching, and here is that list.

I've listed content that is both free and paid. It's not that one type is superior; it’s just to give you plenty of choices. These are the resources that I've used and do still use to re-learn Java. So, if you're new to Java or looking to pick it up again after a break, this blog is for you.

How to Check Text Inputs for SQL Injection Attacks in Java

SQL (Structured Query Language) injection is a code injection technique used to attack data-driven applications; the SQL statements are inserted into an entry field for execution and wreak havoc from there. This type of attack tends to seek and target existing security vulnerabilities within websites or other databases to acquire access to sensitive information. For example, if the field of an online form is coded incorrectly, this provides an opening for the malicious user to sneak in SQL commands that the system will consider valid and return a response containing information that can be leveraged to access the data and manipulate, modify, or destroy it from there.

Despite the growing number of organizations that have reported successful SQL injection attacks, this type of threat is often underestimated in comparison to other cyber-crimes. Due to their reliance on check-out forms for their websites, retail companies have shown to be particularly susceptible to these threats. While standard firewalls may aim at protecting your website or application from SQL injection, the potential for failure can cause serious damage and data loss for your company. The following APIs can assist in providing supplementary protection by detecting SQL injection attacks from single or multiple text inputs, and will even define the threat detection level you want to utilize.

Handling Events With GServlet

Introduction

In my previous article, Creating Filters With GServlet, we learned how to create filters with the GServlet API for an elegant implementation with the Groovy language. In this one, we are going to cover how to handle Servlet events. During the lifetime of a typical Java EE web application, a number of events take place and the Servlet API provides a number of listener interfaces that we can implement.

ServletContextListener

How to Convert MP4 to MP3 in Java

Extracting audio data from video content can be an arduous process, particularly when attempted by hand. If you need to perform the task with large stacks of data, it can become seemingly impossible or at least prove to be a major time vacuum. Therefore, finding an appropriate API to handle the job for you means that you will be able to efficiently produce high-quality work without losing labor hours or team members to a fairly menial task.

In this tutorial, I will show you how to convert video files to different audio file formats using four Video and Audio APIs. These include MP3, M4A, WAV, and AAC. Because we have quite a few functions to the walkthrough, we will just jump in now.

How to Resize a Video in Java

With the vast genres of online media platforms, like social media, online video sites, and more, there are more opportunities than ever before to share your products and content globally. With websites like YouTube, Twitter, and Facebook, and apps like Snapchat and Instagram, your organization’s reach can grow exponentially by advertising to or interacting with audiences with varying demographic profiles. Furthermore, making video content that is easily accessible to your users for topics like tutorials, best practices, or news updates creates a user-friendly, passive way for your audience to learn more about you, where classic news articles often require more in-depth reading.  

With these sites, however, often the formatting for video sharing changes from one platform to the next. This may not be an issue if your content does not need to maintain a specific aspect ratio to convey your message. However, if you have formatted your video in a specific way to meet the needs of a genre or desired look, resizing your video while preserving its original aspect ratio will allow you to transfer it between platforms without losing quality or aesthetic value.

How to Encrypt PDF Documents in Java

Proper documentation, intensive contracts, and extensive manuals form the backbone of the business, though, in modern business, much of this is retained digitally using document file formats such as PDF. Because your organization relies on so many of these forms of documentation, it is integral that you can protect the contents within from errors or outside threats. For the proper precautions to be put in place, utilizing encryption and permissions settings will ensure your PDF documents are only used in ways you deem fit, and cannot be accidentally or maliciously altered by other entities. 

Setting these parameters on each document, however, is a daunting and time-consuming task, and, if it is mistakenly forgotten, it can lead to major issues for you and your organization. By using the following two APIs, you can cut this risk as each document will be automatically encrypted with password protection. This password protection includes an owner password to control editor/creator permissions and a user password to control who can view the PDF.

How To Install TestNG In Eclipse: Step By Step Guide

As you already know, TestNG or Test Next Generation is one of the most frequently used automation testing frameworks in Java. Inspired by JUnit and NUnit, Cedric Beust created TestNG with the idea of covering almost all types of testing models, be it functional or end-to-end. The annotations, functionalities, usability, features, and ease-of-use make TestNG a very popular choice of framework. Listed below are some of the major benefits of using TestNG-

  • The reporting feature provides a detailed XML report of every successful, failed, or skipped test.

Java String Tutorials: Become a Java Strings Virtuoso

Intro to Java Strings

Java String
Get Ready to Learn About Java Strings!
  1. String Memory Internals by Tomasz Murkiewicz. The main point to understand here is the distinction between String Java object and its contents - char[] under private value field. String is basically a wrapper around char[] array, encapsulating it and making it impossible to modify so the String can remain immutable. Also the String class remembers which parts of this array is actually used. This all means that you can have two different String objects (quite lightweight) pointing to the same char[].

  2. Top 10 Questions of Java Strings by Ryan Wang. A discussion of ten common questions Java developers face when working with Strings. Though this is a bit of an old post (published in 2013), we hope you'll still find some value in these lessons. 

SOAP Web Services With Apache CXF and Spring Boot

This post is based on one I wrote a few years ago about building contract first web services with Apache CXF and Spring. The previous post didn't use Spring Boot and most of the Spring and CXF configuration was via XML. This post moves things forward a bit by using the latest version of CXF and Spring Boot.

Sample App

We're going to build a simple Spring Boot app that exposes SOAP web service using Apache CXF. The service will have a single operation that takes an account number and returns bank account details. If you're impatient and want to jump ahead you can grab the full source code from GitHub.

Fetching Data With ORMs Is Easy! Is It?

Introduction

Almost any system operates with external data stores in some way. In most cases, it is a relational database and very often data fetching is delegated to some ORM implementations. ORM covers a lot of routine operations and brings along a few new abstractions in return.

Martin Fowler wrote an interesting article about ORM and one of the key thoughts there is “ORMs help us deal with a very real problem for most enterprise applications... They aren't pretty tools, but then the problem they tackle isn't exactly cuddly either. I think they deserve a little more respect and a lot more understanding.”

Spring Boot and GCP Cloud Pub/Sub

In this post, we will explore how we can use Google Cloud Platform’s (GCP) Pub/Sub service in combination with a Spring Boot application using Spring Integration. We will send a message to a sender application which publishes the message to a Topic where a receiver application receives the messages of a Subscription.

Introduction

GCP Pub/Sub is basically just like any other messaging system. You can send a message to a Topic where it is persisted, then a subscriber consumes the message, and after acknowledgment, the message is removed.

Positions to Addresses With Gesture Events and HERE in Android

I've been writing a few tutorials on using the HERE Location Services (HLS) platform with Android. These tutorials have included showing a map, dropping markers, and geocoding address information to latitude and longitude position information. This time around we're going to take things to the next level by converting latitude and longitude position information to address information within an Android application.

To be specific in what we plan to accomplish, take a look at the following animated image.

How to Manage Transactions in Redis on Java

Transactions in Redis allow the execution of a group of commands to take place in a single step. Managing Redis transactions on Java can be tricky for some users, but it is much easier when you have the right tools at your disposal. In this post, you will learn all you need to know about the execution of Redis transactions on Java, as well as getting a brief insight into Spring Transaction Manager and XA Transactions for Redis.

Overview of Redis Transactions on Java

Redis transactions are atomic, meaning that either all the commands in the transaction are processed or none of them are. The commands are sequentially executed as a single isolated operation, with no option for a request issued by another client to be served in the middle of the execution of the transaction.

Spring Boot: Run and Build in Docker

There are a lot of guides on “Docker for Java developers,” but most of them do not take care of small and efficient Docker images.

I have combined many resources on how to make a simple and fast Docker image containing any Spring Boot-like application.

Threads Stuck in java.net.SocketInputStream.socketRead0 API

What does the java.net.SocketInputStream.socketRead0() API do? Why is it showing up frequently in thread dumps? Why is it reported in thread dump analysis tools like fastThread.io? Is it something that I need to be concerned about? What are the potential solutions to this problem? Let’s find answers to these questions.

What Does the SocketInputStream.socketRead0() API Do?

It’s always easy to remember new concepts through real-life analogies. Suppose you are calling your wife or girlfriend on the phone. Once the call gets connected, if she is in a good mood, you will get the response: “Hello, Honey, how are you?” If your call got connected when she is in middle of doing work (say she is in her office, picking up kids, at the gym, etc.), there might be a delay in her response:  “Hello, Honey...” Suppose your call got connected when she is upset. You might get a response after several seconds/minutes. So, the time you are waiting since the moment call got connected until the moment you hang up the call is basically the socketRead0() API. (Thanks to Douglas Spath from IBM for giving this beautiful example to explain this SocketRead0() API.)