Java Posts

The Toptal Engineering Blog is a hub for in-depth development tutorials and new technology announcements created by professional software engineers in the Toptal network.
Kevin Bloch
Haxe: Cross-platform Development's Best-kept Secret

The modern, cross-platform programming language Haxe is well-known in some circles, yet many developers have never heard of it. Since it first appeared in 2005, it’s been battle-tested by its loyal—if rather quiet—following.

In this article, Toptal Freelance Software Engineer Kevin Bloch explores the Haxe ecosystem and how to transpile some sample code.

Continue reading →
Ivan Cesar
An Elasticsearch Tutorial for .NET Developers

Elasticsearch is one of the most powerful full-text search engine solutions out there. Using the NEST package, you can easily leverage the power of Elasticsearch in your .NET projects.

In this article, Toptal Freelance Software Engineer Ivan Cesar shows how Elasticsearch can solve real-world full-text search problems in your .NET projects.

Continue reading →
Dusan Simonovic
Get Started With Microservices: A Dropwizard Tutorial

Dropwizard allows developers to quickly bootstrap their projects and package applications as easily deployable standalone services. It also happens to be relatively simple to use and implement.

In this tutorial, Toptal Freelance Software Engineer Dusan Simonovic will introduce you to Dropwizard and demonstrate how you can use this powerful framework to create RESTful web services with ease.

Continue reading →
Brad Peabody
Server-side I/O Performance: Node vs. PHP vs. Java vs. Go

Understanding the Input/Output (I/O) model of your application can mean the difference between an application that deals with the load it is subjected to, and one that crumples in the face of real-world uses cases. Perhaps while your application is small and does not serve high loads, it may matter far less. But as your application’s traffic load increases, working with the wrong I/O model can get you into a world of hurt.

Continue reading →
Shanglun Wang
How to Build a Natural Language Processing App

Natural language is increasingly becoming a viable way of interacting with smart software. Google search, Apple’s Siri, Microsoft’s Cortana, etc. are all capable of understanding queries in natural language.

In this article, Toptal Freelance Software Engineer Shanglun (Sean) Wang walks us through some useful concepts and techniques in natural language processing and shows how they can be used to build a simple NLP app.

Continue reading →
Eugene Ossipov
Genetic Algorithms: Search and Optimization by Natural Selection

Many problems have optimal algorithms developed for them, while many others require us to randomly guess until we get a good answer. Even an optimal solution becomes slow and complex at a certain scale, at which point we can turn to natural processes to see how they reach acceptable results.

In this article, Toptal Freelance Software Engineer Eugene Ossipov walks us through the basics of creating a Genetic Algorithm and gives us the knowledge to delve deeper into solving any problems using this approach.

Continue reading →
Miguel García López
Write Fat-free Java Code with Project Lombok

Java has some idiosyncrasies of its own and design choices that can make it rather verbose. While Java is a mature and performant programming language, developers frequently need to write boilerplate code that bring little or no real value other than complying with some set of constraints and conventions.

In this article, Toptal Freelance Software Engineer Miguel García López shows how Project Lombok can help dramatically reduce the amount of boilerplate code that needs to be written in a Java application.

Continue reading →
Eliran Goshen
Android Threading: All You Need to Know

Android provides many ways of creating and managing threads, and third-party libraries exist to make that even easier. However, with so many options, choosing the right approach can be quite confusing.

In this article, Toptal Freelance Software Engineer Eliran Goshen discusses some common scenarios in Android development that involve threading and how each of the scenarios can be dealt with.

Continue reading →
Ivan Pavlov
A Unit Testing Practitioner's Guide to Everyday Mockito

Using Mockito is not just a matter of adding another dependency. It requires changing how you think about your unit tests while removing a lot of boilerplate.

In this article, we’ll cover multiple mock interfaces, listening invocations, matchers, and argument captors, and see firsthand how Mockito makes your tests cleaner and easier to understand.

Continue reading →
Joshua Hayden
A Guide to Robust Unit and Integration Tests with JUnit

Automated software tests are critically important to the long-term quality, maintainability, and extensibility of software projects, and for Java, JUnit is the path to automation.

While most of this article will focus on writing robust unit tests and utilizing stubbing, mocking, and dependency injection, Toptal Software Engineer Josh Hayden will also discuss JUnit and integration tests.

Continue reading →
Grzegorz Gajos
How Hibernate Almost Ruined My Career

Are you building the next big thing? Planning to become the next Facebook or Google? Are you at the point of making fundamental decisions that will stay with you for the entire project? There is a good chance that you will pick a robust language like Java. If so, you want to pick the best object-oriented abstraction of your flexible data model because you don’t want to deal with plain SQL. You want to support all kinds of data and ideally, support all kind of databases. If so, there’s is only one right choice for you: Hibernate.

Continue reading the story written by Freelance Software Engineer Grzegorz Gajos, about one of these imaginary but entirely possible scenarios.

Continue reading →
Christopher Arriola
Meet RxJava: The Missing Reactive Programming Library for Android

Implementing applications that deal with complex concurrent behavior has always been a challenging aspect of programming. Various paradigms exist that promise a solution to this problem in different ways. RxJava is a Java library that enables Functional Reactive Programming in Android development. It raises the level of abstraction around threading in order to simplify the implementation of complex concurrent behavior.

In this article, Toptal Freelance Software Engineer Christopher Arriola gives us a detailed walkthrough of RxJava and how it fits into the realm of Android development.

Continue reading →
Ivan Kušt
Ten Kotlin Features To Boost Android Development

Kotlin is a new, expressive general-purpose programming language powered by the same virtual machine technology that powers Java. Since Kotlin compiles to the JVM bytecode, it can be used side-by-side with Java, and it does not come with a performance overhead.

In this article, Toptal Freelance Software Engineer Ivan Kušt gives us a walkthrough of ten major features of Kotlin that help avoid boilerplate code and, more importantly, save time.

Continue reading →
Matko Šuflaj
Java in the Cloud: Continuous Integration Setup Tutorial

More than two decades ago, Java shook the world with its “Write once, run anywhere“ slogan. Today, Java developers have at their disposal a whole set of tools, such as Spring Boot, Docker, Cloud, Amazon Web Services, and Continuous Delivery, to take development and delivery to a whole new universe.

In this article, Toptal Freelance Software Engineer Matko Šuflaj presents all these technologies and guides us through a step-by-step tutorial on how to build a small microservice and prepare it for continuous integration in the cloud.

Continue reading →
Gregor Ambrozic
Why Should Java Developers Give Grails a Chance?

Java may have stood the test of time, but it can still be a source of great frustration among many web developers. Dealing with its verbosity and infrastructure overhead, for example, can take hours, even for the most basic needs.

In this article, Toptal Freelance Software Engineer Gregor Ambrozic shows us how Grails and its many appealing features can be a viable alternative to traditional Java web applications frameworks.

Continue reading →
André William Prade Hildinger
How to Build a Multitenant Application: A Hibernate Tutorial

In the realm of enterprise software, especially for software provided as a service, multitenancy ensures that data is truly isolated for each client within a shared instance of software. Among its numerous benefits, multitenancy can greatly simplify release management and cut down costs.

In this article, Toptal Freelance Software Engineer André William Prade Hildinger shows us how Hibernate, a persistence framework for Java, makes implementing a multitenant Java EE application easier than it sounds.

Continue reading →
Francis Altomare
A New Way of Using Email for Support Apps: An AWS Tutorial

Of all the modern ways people talk to each other, email seems to have stood the test of time and is arguably still one of the most effective and widely used means of communication. Thus, being able to programmatically send and receive emails can open new dimensions to a user’s experience of software that powers human communication.

In this article, Toptal Freelance Software Engineer Francis Altomare shows us how he leveraged various Amazon Web Services technologies to build a simple communication application in which email itself is an important interface.

Continue reading →
Tomasz Czura
Introduction to Kotlin: Android Programming For Humans

Java has been a dominant programming language for ages, but modern times call for modern languages. Meet Kotlin, a modern, clear, and expressive programming language powered by the same virtual machine technology that powers Java.

In this article, Toptal Freelance Software Engineer Tomasz Czura takes us for a spin through the world of Kotlin and shows us how it can be used to make an Android application with an elegant architecture without compromising the very qualities of the code that Kotlin aims to provide.

Continue reading →
Tibor Kaputa
Tips And Tools For Optimizing Android Apps

The plethora of tutorials on building Android apps may have you thinking that making a mobile app is simple. In reality, however, performance issues can be very complicated, and because performance plays a key role in making sure that your app stays on your users’ list of favorite apps for a long time, every little detail must be given one’s full attention.

In this article, Toptal Freelance Software Engineer Tibor Kaputa shares some tips on how you can optimize some common performance issues and identify some of the bottlenecks in your Android app.

Continue reading →
Michele Sciabarra
Scaling Scala: How to Dockerize Using Kubernetes

Are you a Scala developer hoping to scale your application in the cloud? If so, meet Kubernetes, a cluster manager for Docker applications. Developed by Google, it’s the latest in new open source tools making major waves.

In this article, Toptal Freelance Software Engineer Michele Sciabarra guides us through a step-by-step tutorial on how to take a generic Scala application and implement Kubernetes and Docker to launch multiple instances of the application.

Continue reading →
Sergey Reznick
Get Your Hands Dirty With Scala JVM Bytecode

The Scala language has continued to gain popularity over the last several years, thanks to its excellent combination of functional and object-oriented software development principles, and its implementation on top of the proven Java Virtual Machine (JVM).

Creating a language that compiles to Java bytecode requires a deep understanding of the inner workings of the Java Virtual Machine. To appreciate what Scala’s developers have accomplished, it is necessary to go under the hood, and explore how Scala’s source code is interpreted by the compiler to produce efficient and effective JVM bytecode.

Continue reading →
Lovro Iliassich
Clustering Algorithms: From Start To State Of The Art

Clustering algorithms are very important to unsupervised learning and are key elements of machine learning in general. These algorithms give meaning to data that are not labelled and help find structure in chaos. But not all clustering algorithms are created equal; each has its own pros and cons.

In this article, Toptal Freelance Software Engineer Lovro Iliassich explores a heap of clustering algorithms, from the well known K-Means algorithm to the elegant, state-of-the-art Affinity Propagation technique.

Continue reading →
Michele Sciabarra
Using Scala.js With NPM And Browserify

Today, writing applications in languages that compile to JavaScript is a very common practice. Scala developers, for example, can use Scala.js and have the same language for both the server and the client. That said, Scala’s compiler and standard dependency management tools are too limiting in the modern JavaScript world.

In this article, Toptal Freelance Software Engineer Michele Sciabarra shows us how to integrate Scala.js with the plethora of JavaScript modules available on NPM, using tools like Browserify, and explains how to do this without even having to install Node.js.

Continue reading →
Marko Dvečko
Introduction To Concurrent Programming: A Beginner's Guide

Concurrency allows programs to deal with a lot of tasks at once. But writing concurrent programs isn’t a particularly easy feat. Dealing with constructs such as threads and locks and avoiding issues like race conditions and deadlocks can be quite cumbersome, making concurrent programs difficult to write.

In this article, Toptal Freelance Software Engineer Marko Dvečko gives us an overview of some concurrent programming models. He explains how each of these models gives structure to the programs we write and shows how to avoid certain concurrency issues that can come with these models.

Continue reading →
Becze Szabolcs
Android Developer’s Guide to Fragment Navigation Pattern

Navigation in mobile applications, when done right, can have tremendous positive impact on overall user experience. Android offers application developers multiple ways of implementing navigation in their application. However, not all navigation patterns are created equal.

In this article, Toptal engineer Becze Szabolcs shows us how to implement fragment-based navigation and how it stacks up against Android’s traditional navigation philosophy.

Continue reading →
Cong Liu
Caching in Spring with EhCache Annotations

EhCache is a widely-used, pure Java cache that can be easily integrated with most popular Java frameworks, such as Spring and Hibernate. It is often considered to be the most convenient choice for Java applications since it can be integrated into projects easily. EhCache Spring Annotations allows seamless integration into any Spring application by simply adding annotations to cacheable methods, without modifying the method implementations. This article focuses on boosting your Spring applications with EhCache Spring Annotations.

Continue reading →
Federico Tomassetti
Creating Usable JVM Languages: An Overview

Java Virtual Machine (JVM), the powerful virtual machine behind programming languages like Java and Scala, provides a platform-independent environment for executing compiled bytecode. Programming languages built for the JVM can be used to write programs that can run on a wide range of platforms without modification and can even leverage all the libraries and frameworks that exist for the JVM.

In this article, Toptal engineer Federico Tomassetti presents an overview of the strategy and various tools involved in creating our very own programming language for the JVM.

Continue reading →
Dejan Milosevic
REST Security with JWT using Java and Spring Security

Although the old, standardized security approaches work with REST services, they all have problems that could be avoided by using a better standard. For this, JWT arrives just in time to save the day.

In this article, Toptal engineer Dejan Milosevic guides us on how to implement a JWT token-based REST API using Java and Spring Security.

Continue reading →
Oguz Gelal
Ultimate Guide to the Processing Language Part I: The Fundamentals

Rapid prototyping and the ability to produce quick visual results are features of many programming languages and frameworks. However, some take it even further by making these their primary goals. Processing, a programming language based on Java, allows its users to code within the context of visual arts and has been designed from the ground up to provide instant visual feedback. In this article, Toptal engineer Oguz Gelal provides a gentle introduction to Processing and some insights into its inner mechanics.

Continue reading →
Nick McCrea
Learn to Code: Wisdom and Tools for the Journey

It’s no surprise that more and more people, from all kinds of backgrounds, are deciding to learn to code. But, each person who tackles the task is soon faced with an unpleasant reality: Learning to program is hard. Contrary to expectations, the feeling of “I don’t get it,” may persist unabated long into the journey, making once bright-eyed beginners feel hopeless, lost, and ready to give up.

The moral of the story is this: Be prepared. The path to programmer paradise is a long one, and without the right mindset at the beginning, it can quickly lose its appeal. In this article, I’ll attempt to give you some guidance on what to expect on your journey, how best to go about it, and what tools and resources you may find helpful along the way.

Continue reading →
Alberto Mancini
The GWT Toolkit: Build Powerful JavaScript Front Ends Using Java

The GWT Web Toolkit, formerly known as Google Web Toolkit, is a set of development tools for building and optimizing complex browser-based applications using the Java programming language. What makes GWT not “yet another Java tool to write web apps,” is the fact that the heart of the toolkit is a compiler that converts Java into JavaScript, enabling developers to write front-end web applications while leveraging all of Java’s strengths.

Continue reading →
Igor Delac
Implementing a Remote Framebuffer Server in Java

Connecting to remote computers and working on them through terminals over a network is something we often take for granted. Technologies that enable us to do this have changed the way we work and have opened doors to amazing possibilities. Although the inner workings of these technologies may seem like obscure knowledge, implementations of many of these technologies are surprisingly straightforward. In this article, Toptal engineer Igor Delac gives us a step-by-step tutorial on how to implement the Remote Framebuffer server-side protocol in Java, allowing Swing-based applications to run and be interacted with remotely using standard VNC clients.

Continue reading →
Dejan Zivanovic
Automation in Selenium: Page Object Model and Page Factory

Proper test automation is not always easy to achieve and requires almost as much design and thought as needed for the software itself. In the agile way of development tests are an essential ingredient in ensuring quality of software. However, unless these test codes are maintainable, they can prove to be more of a nuisance, especially when it comes to automated testing of modern web applications. This article is an easy introduction to Selenium features Page Object and Page Factory, how they can be used to model web applications, and how to write maintainable test code using them.

Continue reading →
Eduard Grinchenko
Why You Need to Upgrade to Java 8 Already

The newest version of the Java platform, Java 8, was released more than a year ago. Many companies and developers are still starting new applications with old versions of Java. There are very few good reasons to do this, because Java 8 has brought some important improvements to the language. I’ll show you a handful of the most useful and interesting ones.

Continue reading →
Stefan Varga
Building an MVC Application with Spring Framework: A Beginner's Tutorial

The Spring Framework is a powerful, feature-rich, and well-designed framework for the Java platform. It offers a collection of programming and configuration models that aim to simplify and streamline the development process of robust and testable applications in Java. In this article, Toptal engineer Stefan Varga challenges the popular notion of Java as a complicated platform for simple needs, and walks us through a step by step tutorial to building a simple MVC application with the Spring Framework and JPA.

Continue reading →
Asa Kaplan
OpenGL Tutorial for Android: Building A Mandelbrot Set Generator

OpenGL, a cross-platform API for rendering 2D and 3D graphics, is extremely powerful and yet surprisingly easy to get started with. Although one may find the most common applications of OpenGL and rendered graphics in video games only, in reality there are far more uses. To demonstrate the power of OpenGL, we’ll be building a Mandelbrot set generator on Android using OpenGL ES.

Continue reading →
Ahmed Al-Amir
Android Customization: How to Build a UI Component That Does What You Want

It is not uncommon for developers to find themselves in need of a UI component that is either not provided by the platform they are targeting or is, indeed, provided, but lacks a certain property or behavior. The answer to both scenarios is a custom UI component. The Android UI model is inherently customizable, offering the means to create custom UI components in various ways.

Continue reading →
Doug Sparling
Full Text Search of Dialogues with Apache Lucene: A Tutorial

Apache Lucene is a powerful Java library used for implementing full-text search on a corpus of text. With its wide array of configuration options and customizability, it is possible to tune Apache Lucene specifically to the corpus at hand - improving both search quality and query capability.

This article gives us a glimpse of the simplicity and ease of customization of the Apache Lucene analysis pipeline.

Continue reading →
Nermin Hajdarbegovic
Toptal’s Selection Of Best Developer Blogs

You are what you read – and most Toptal members and blog subscribers are software developers. So what do you read? Where do professional developers get the latest information about how their peers work and think?

Today, we will be taking a look at a small selection of popular developer blogs frequented by Toptal developers. We’re counting on you (our readers) to expand the list in the comment section.

Continue reading →
Mikhail Selivanov
Buggy Java Code: The Top 10 Most Common Mistakes That Java Developers Make

Java, a sophisticated programming language, has been dominating a number of ecosystems for quite a while. Portability, automated garbage collection, and its gentle learning curve are some of the things that make it a great choice in software development. However, like any other programming language, it is still susceptible to developer mistakes.

This article explores the top 10 common mistakes Java developers make and some ways of avoiding them.

Continue reading →
Alberto Mancini
How GWT Unlocks Augmented Reality in Your Browser

In our previous post on the GWT Web Toolkit, we discussed the strengths and characteristics of GWT, to mix Java and JavaScript libraries seamlessly in the browser. In today’s post, we would like to go a little deeper, and see the GWT Toolkit in action. We’ll demonstrate how we can take advantage of GWT to build a peculiar application: an augmented reality web application that runs in real time, fully in JavaScript, in the browser. We’ll focus on how GWT gives us the ability to interact easily with many JavaScript APIs, such as WebRTC and WebGL, and allows us to harness a large Java library, NyARToolkit, never intended to be used in the browser.

Continue reading →
Jovan Jovanovic
How does Shazam work? Music Recognition Algorithms, Fingerprinting, and Processing

You hear a familiar song in the club or the restaurant. You listened to this song a thousand times long ago, and the sentimentality of the song really touches your heart. You desperately want to heart it tomorrow, but you can’t remember its name! Fortunately, in our amazing futuristic world, you have a phone with music recognition software installed, and you are saved.

But how does this really work? Shazam’s algorithm was revealed to world in 2003. In this article we’ll go over the fundamentals of that algorithm.

Continue reading →
Lê Anh Quân
Advanced Java Class Tutorial: A Guide to Class Reloading

In Java development, a typical workflow involves restarting the server with every class change, and no one complains about it. But is Java class reloading that difficult to achieve? And could that problem be both challenging and exciting to solve? In this article, I will try to address the problem, help you gain all the benefits of on-the-fly class reloading, and boost your productivity immensely.

Continue reading →
Ivan Dimoski
Tips for Developing an Android App: My Lessons Learned

This article provides an overview on building a great Android application, from defining an idea to releasing an application to the store. Toptal developer Ivan Dimoski gives us a chance to learn from his experience in making Ooshies, an Android Live Wallpaper designed to give you a hug and make you feel loved each time you interact with your Android device.

Continue reading →
Ivan Dimoski
Top 10 Most Common Mistakes That Android Developers Make: A Programming Tutorial

There are thousands of different Android powered devices, with different screen sizes, chip architectures, hardware configurations, and software versions. Unfortunately, segmentation is the price to pay for openness, and there are thousands ways your app can fail on different devices.

Regardless of such huge segmentation, the majority of bugs are actually introduced because of logic errors. These bugs are easily prevented, as long as we get the basics right!

Here’s a quick rundown of the 10 most common mistakes Android developers make.

Continue reading →
Radan Skoric
Great Developers Know When and How To Refactor Rails Code

If it ain’t broke, don’t fix it.

It’s a well known phrase, but as we know, most of the human technological progress was made by people who decided to fix what isn’t broken. Especially in the software industry one could argue that most of what we do is fixing what isn’t broken.

Fixing functionality, improving the UI, improving speed and memory efficiency, adding features: these are all activities for which it is easy to see if they are worth doing, and then we argue for or against spending our time on them. However, there is an activity, which for the most part falls into a gray area: refactoring, and especially large scale refactoring.

Continue reading →
Jose Ferreirade Souza Filho
Hunting Java Memory Leaks

Inexperienced programmers often think that Java’s automatic garbage collection frees them from the burden of memory management. This is a common misperception: while the garbage collector does its best, it’s entirely possible for even the best programmer to fall prey to crippling memory leaks.

In this post, I’ll explain how and why memory leaks occur in Java and outline an approach for detecting such leaks with the help of a visual interface.

Continue reading →
Anna-Chiara Bellini
The Trie Data Structure: A Neglected Gem

From the very first days in our lives as programmers, we’ve all dealt with data structures: Arrays, linked lists, trees, sets, stacks and queues are our everyday companions, and the experienced programmer knows when and why to use them.

In this article we’ll see how an oft-neglected data structure, the trie, really shines in application domains with specific features, like word games.

Continue reading →