Introduction to Java development: guide with first steps

Discover how a person just starting out in their development career decides to choose Java

Bruno Lellis

💻 Software Developer at iFood

The Java language has a multitude of mature tools, libraries and frameworks ready to be chosen according to the needs of your projects. This number is proportional to your age: 27 years recently completed is a good indication of the maturity of the language and its entire ecosystem. And, combined with new features, it highlights strong plans for the future.

How does a person starting a development career decide to choose Java? Given this choice, how do you take the first steps?

It's contradictory to have so many options available and, at the same time, not be able to choose one of them — precisely because there are so many. This series of posts is intended to help anyone who still has questions.

Grab a cup of good coffee and enjoy reading!

The language

The Java language appears at the top of the rankings published as TIOBE index It is StackOverflow search .

Regardless of any research, the language is quite mature for its 27 years, it is fully active in the community (with numerous frameworks and libraries) and a new version is released every 6 months, including a new LTS version ( long-term support ) is declared every 2 years.

In addition to the language, the JVM (Java Virtual Machine) is widely recognized as one of the main virtual machines for runtime.

The ecosystem around the language is complete, ranging from desktop systems, command line, web applications, webservices, APIs, to stream-processing and data storage platforms (big data).

Coveted new features are in development, such as lightweight virtual threads ( Project Loom ), improvements in integration with native code ( Project Panama ), value objects and user-defined primitives ( Project Valhalla ), among others, and that is precisely why Java is becoming an excellent tool for solving an increasing number of software development tasks.

Where are we

The immense amount of options accumulated over almost 3 decades can be an inherent challenge for people just starting their careers. Which version should I use? Why so many options? How to install 2+ versions without conflicts? Which tools (IDE) to use? All of these (and any other) questions have more than one answer option, and this can end up putting a strain on the career of someone new to Java technology.

Many famous tools in the past practically no longer exist, others have evolved into new versions. A point to pay attention to in these cases, as everything is available on the Internet and it can be difficult to identify what is relevant from what has fallen into disuse.

Opinionated Guide

The idea of this post is to serve as an opinionated guide for people who are starting Java development in 2023, helping you with your first steps on this incredible platform.

Remember that decisions are personal, they are my recommendations and they may differ from yours without any problem.

Here's a warning: I don't claim to be the owner of the truth. There are several options and considerations that must be taken in each choice. There is no right or wrong and, often, it is a trade-off. My intention is to help you make your first choices by considering the more comprehensive options. As your experience takes shape, you begin to form your opinion and, at that moment, you will be able to continue with your decisions, without depending on guidelines and ends.

Java ecosystem

At first, it can be confusing to understand what Java really is.

The Java programming language

It is an object-oriented, statically typed, general-purpose programming language (with a few hints of functional language). The code is compiled to a portable byte-code that is interpreted by a virtual machine, that is, it can be executed on several operating systems different from where it was initially compiled.

The Java Platform

The Java universe is a vast set of technologies, made up of three main platforms that were created for specific application segments. .

The key elements here are the Java compiler (javac); a virtual machine (JVM) and a language standard library. The purpose of this post is the Java Standard Edition (SE) version, as other Java Micro Edition (ME) and Jakarta Enterprise Edition (EE) will not be discussed here.

Many other languages can be run on the JVM besides Java itself, such as Kotlin, Groovy, Scala.

A Java Virtual Machine (JVM)

It is a virtual machine responsible for executing programs written in Java (or rather, the byte-code), that is, taking care of tasks such as loading the byte-code and verifying its accuracy, compiling this byte-code into native code using a compiler just-in-time (JIT), automated memory management via garbage collection, isolation between different components, provision of data for runtime diagnostics, etc. There are several implementations of JVM like Hot spot , OpenJ9 , Zulu Blue , among others.

The Java Development Kit (JDK)

A package of tools for developing and running Java applications.

OpenJDK

An open source implementation of Java SE. It is also the name of the open-source community that takes care of this implementation.

The Java Community Process (JCP)

A group for developing new specifications in the Java world, including different versions of Java.

📦 Distribution

The Java platform is maintained by the OpenJDK project open source. Similar to Linux, several vendors make binaries available for the project, including Amazon, the Eclipse foundation, Microsoft, Oracle and Red Hat. These distributions differ in aspects such as commercial support, supported platforms, some with different garbage collectors. Many providers offer a free version as well. So which one should I use?

At first, the difference doesn't matter so much and the suggestion is to start with Eclipse Temurin . This version is supported by groups of companies such as Google, Red Hat, Microsoft, Alibaba, Azul and others. You can download and use it for free, it contains everything you need, it is compatible with the JDK Test Compatibility Kit (TCK) — that is, it is an “approved” JVM — and, if necessary, it has commercial support available from different suppliers.

📆 Version

A new version of Java is released every 6 months. The current version at the time of writing this post is for Java 19 . Specific versions are considered extended support ( long-term support or LTS), where each vendor responsible for the JVM provides maintenance for a few years. The LTS version is currently Java 17 and the recommendation is to choose this version , right now.

There are currently newer versions (18 and 19) that are not LTS and have interesting features, but it can be a challenge to keep your applications updated in a sustainable way, not to mention that many of these new features may still be in the testing phase ( preview ) or incubated — you will end up not using this in production. The recommendation, in this case, is to venture into these versions when you have a little more experience.

If any third-party library is not yet supported by Java 17, you should look for a previous LTS version, which in this case is Java 11. Try to avoid using non-LTS versions, as they do not have long-term maintenance commitments. that is, you may be experiencing a security issue without any visibility into fixes or bugs. An important note: do not use Java 8 (or 1.8, as it was called at the time), which would be the LTS version before 11, as it is already very old.

🔧 Installation

There are a few ways to install the chosen version. You can usually find a package that you can install on the vendor's website. You can also use a package manager available in your Linux version.

My recommendation is to start with a simpler way, which is through the SDKMan . This tool helps you install software (SDKs) and other possible tools for development. SDKMan also manages future installations as well as multiple installed versions easily and without conflicts.

If you already have SDKMan installed, do this to get version 17:

				
					$ sdk install java 17.0.5-tem # Install $ sdk use java 17.0.5-tem # Select $ java --version # Check version openjdk 17.0.5 2022-10-18 ...
				
			

Installation on Windows SDKMan is done in bash, so if you use Windows, you will need Windows Subsystem for Linux (WSL) or Cygwin first. Another option would be to use the winget package manager or download the package directly from the vendor's website.

💡Your First Program

After installing Java, let's create the first program. Java is a primarily object-oriented language, so everything in Java is defined using classes, which have attributes (represent their state) and methods (allow you to change the internal state). As usual, your first Hello world!

				
					public class HelloWorld { // #1 public static void main (String... args) { // #2 System.out.println( "Hello world!" ); //#3 } }
				
			
  1. One class HelloWorldmust be specified in a file with the same name ( HelloWorld.java);

  2. The method main()is the entry point of a Java program;

  3. The method println()prints the text to standard output ( stdout or standard output ).

 

Java code is compiled to a file classand which is later loaded into the JVM to be executed. This is generally done in two steps: 1) compile using the javac ; 2) run the binary with the Java . To simplify, it is possible to perform both commands at once:

				
					$ java HelloWorld.java Hello world!
				
			
  1. For didactic purposes and quick exploration there is the jshell , which is a REPL (Read-Evaluate-Print-Loop). It is possible to execute simpler commands without the need to declare packages, classes, etc.:
				
					$ jshell jshell> System.out.println( "Hello World" ); Hello World
				
			

Similar to jshell there is also jbang , which is a little more advanced, allowing the import of third-party libraries.

📚 Learning the Language

Providing an introduction to all the basic functionality of the Java language is beyond the scope of this post. To really learn the language and its details, my recommendation is to pick up a good book, a good cup of coffee (several) and study, following your preferences.

Some popular book recommendations: “Head First Java, 3rd Edition” , written by Kathy Sierra, Bert Bates, Trisha Gee, supplemented by “The Well-Grounded Java Developer, 2nd Edition” , by Benjamin Evans, Jason Clark and Martijn Verburg. A must-read to improve your Java skills is the “Effective Java, 3rd Edition” by Joshua Bloch. The latest edition was written based on Java 9, but the content is not tied to the version itself and applies even to current versions.

If you don't like buying and reading books, there is the guide “Learn Java” in the website dev.java . There are several materials about the language, the JVM and its most important tools in great detail.

Another option that may interest many people is to study through courses. Here in Brazil we have Alura, with several good courses in Portuguese and even a Java career . Another option that usually has discounts and affordable prices is at Udemy , with good courses in Portuguese and English. YouTube is another source of knowledge (just be careful with the amount of content and suggestions that can take your focus away)

If you like certification there is a “Oracle Certified Professional: Java SE 17 Developer” . I recommend that you work at least 2 years with the language, to get used to it, and also study during this period, as certification is relatively difficult and has a lot of pitfalls.

Regardless of which study options you like, the important thing is to maintain a frequent study routine. Try studying a little every day and it will become a lifelong habit.

📜 Next Chapter

This is the first part of the guide. Take the opportunity to study the language and delve deeper. In the second part, we will cover tools for building your project, editors and IDEs, libraries and frameworks, among other details. Don't miss it!

You find the second part of this guide here .

Was this content useful to you?
YesNo

Related posts