In order to develop Java applications or Java APIs you need the Java Software Developer Kit (Java SDK) installed. You should install the Java SDK you want to use. At the time of writing this, I am using the several different JDKs. I use Java 8 SDK for some types of apps, and Java 13 for others. The latest “Long Term Support” (LTS) version is Java 11 (as of Feb. 2020).
Since April 2019 Oracle has changed the licensing for the Java SDK they offer. The Oracle Java SDK is now no longer free to use in production. However, there exists a free OpenJDK alternative which has most of the same features. Some of the high end enterprise features are missing, but often you will not need those.
To find the right installation, simply search online for “Java SDK 13” or “OpenJDK 13” and you will find the right installation packages quickly.
Once you have installed the Java SDK, test that you have it working by opening a command prompt (textual interface to your computer, ala Unix Shell, Windows CMD etc.) and type:
If the Java SDK was probably installed you should see an output similar to this:
C:\Users\jjenkov>java -version java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b18) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Installing Multiple Java SDKs
If you are maintaining older Java projects you may need to have multiple Java SDKs installed. This is possible. However, typically it will be the latest version which is executed when you type
java in the command prompt. In order to run an older Java SDK, write the full path to where the
javac or whatever command you need) is located in the older Java SDK.
If you are using an IDE, they can typically handle this for you. Typically you set a Java SDK for the project, point to where that Java SDK is installed on your machine, and the IDE takes care of using it for compiling and running your Java code.
Installing a Java IDE
If you plan to be working more seriously with Java, I would recommend that you install a Java IDE (Integrated Development Environment). An IDE contains both a code editor with syntax highlighting, code completion, code generation, often with version control system integration and more. An IDE also makes it easy to compile and run your Java code, all from within the IDE.
Here are the three most popular Java IDEs:
- IntelliJ IDEA
Personally I use IntelliJ IDEA, but I have used all three IDEs over the years, and all of them are pretty good nowadays. IntelliJ IDEA has a free community edition which is enough for you to get started with Java. Eclipse and Netbeans are completely free.