1. The modern Java development environment for OSX

If your personal computer is manufactured from Apple, the following instructions will help you.

1.1. Package manager

In OSX, you have excellent package managers like HomeBrew and Sdkman. Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system. SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems.

Using Homebrewl, we will install some packages and using Sdkman, we will install others.

Once you have installed both, continue with the next section.

1.2. Java Virtual Machine

To program with Java is necessary to install in your laptop a Java Development Kit (JDK).

A Java Development Kit (JDK) is a program development environment for writing Java applications. It consists of a runtime environment that "sits on top" of the operating system layer as well as the tools and programming that developers need to compile, debug, and run applications written in the Java language.

To begin using Java, it is necessary to install the JDK:

sdk install java

Once you have installed Java JDK, check the installation:

java -version

You should view the following output:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

To check if you are able to compile Java files, create a new file with the name of HelloWorld.java and copy and paste on it the following content:

public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello World" to the terminal window.
        System.out.println("Hello World");
    }

}

Save the file and open in a terminal to type the following commands:

javac HelloWorld.java
java HelloWorld

You should read: HelloWorld in the terminal.

Switching from one Java version to another one

Using sdk, it is very easy to switch from one Java version to another one. Check your JDK installed and package available in Sdk:

sdk list java
sdk use java 10.0.1-open

1.2.1. Build Systems

Modern Java development use dependencies stored on Software Repositories. It is a good idea if you install the popular build Systems as Maven & Gradle for Java. This project is modular and it deliver multiple dependencies.

The way to install Maven & Gradle is:

sdk install maven
sdk install gradle

Further information about Maven & Gradle.

1.3. Java IDE

To develop a single Java file, maybe you could use a simple Text Editor but current Java IDE offers several funcionalities to help you in the process to develop software with Java. In the market, the most popular Java IDE are IntelliJ & Eclipse.

To install IntelliJ:

brew cask install intellij-idea

To install Eclipse:

brew cask install eclipse-java

Further information about IntelliJ & Eclipse

1.4. Source Control Management

Git is a popular technology to manage code. Many ideas that you see on Internet are stored on Git repositories so manage this technology is necessary.

You could use the Version control features from IntelliJ or use a dedicated tool like SourceTree

brew cask install sourcetree

Further information about SourceTree