1. Programming for grown-ups
Until recently, you only wrote programs on the CodeGym website. This was simple, convenient, and understandable. But you don't think that you will always do this, do you? It's time to start writing programs like an adult, just like real programmers. Somehow people were writing programs before CodeGym was created!
To write a program on your computer without CodeGym, you need to do two things:
- Install the Java JDK
- Install the Java IDE
What is these things?
A program written in Java is different from an ordinary computer program. An ordinary program contains machine code that can be executed directly by a computer processor and doesn't require any additional manipulation to run.
A program written in Java doesn't contain machine code. Instead, it contains special bytecode. The processor doesn't know how to execute bytecode, so when executing a Java program, it first launches a special program, the JVM. And it is the JVM that understands bytecode and knows how to execute it. The JVM is part of the JDK.
Modern programs contain millions of lines of code. It would be impossible to write such programs using a basic text editor. Instead, coders use powerful software tools that greatly speed up and simplify their work.
These programs for creating programs are usually called IDEs. IDE stands for Integrated Development Environment.
There are 3 popular IDEs for writing Java programs:
- IntelliJ IDEA
Almost everybody prefers IntelliJ IDEA. Once you get to know it, you will understand why. But first you need to deal with the JVM and JDK.
2. What is the JDK?
JVM stands for Java virtual machine. A regular processor executes machine code, but the JVM executes bytecode This means that the JVM is like a virtual processor/computer.
You'll find that programmers quite often refer to computers/processors as machines. Get used to it: you are also one of them now.
The JVM is good thing, but the JVM alone is useless. Nobody needs a bare processor either. The JVM is typically paired with a set of standard libraries, which include all kinds of collections, lists, and other classes. By the way, a standard library contains several thousands of classes.
The JRE stands for Java Runtime Environment.
The JRE is enough to run lots of Java programs, but it isn't for programmers. For example, the Java compiler is not included in the JRE. And where do you get it?
Java developers have their very own toolkit, the JDK (Java Development Kit). The JDK includes the JRE and the Java-compiler along with other programs that are super useful for Java devs. Here's what the big picture looks like:
The JDK contains the JRE plus tools for Java developers.
The JRE contains the JVM plus a set of standard Java libraries.
The JVM is the Java Virtual Machine.
3. Variants of the JDK
The time has passed when a new version of Java appeared every 3-5 years, and it was a major event. Now a new version of the JDK is released every six months. Google Chrome's example turned out to be contagious :) Additionally, different companies produce their own JDKs.
Microsoft was the first to do this in the late 1990s to crush the increasingly popular Java platform that made programs independent of Windows. Of course, Microsoft lost in court and was forced to release its own more independent Java analogues: the .NET platform and the C# language.
The .NET platform is Microsoft's counterpart to the JRE, and the C# language's initial versions had a one-to-one mapping to the Java language. That said, a lot of water has flowed under the bridge since then.
In any case, today there are several popular JDKs. We are interested in two of them:
- Oracle JDK is the official JDK from the company that created Java. Corporate use now requires some payment, but it is still free for private use and individual developers.
- OpenJDK is a free JDK, also released by Oracle. It is the favorite of developers and companies that don't want to pay money to Oracle.
For developers, there is no fundamental difference, so you can safely use OpenJDK.
4. Installing the JDK
You need to download OpenJDK 16 to your computer. First, go https://jdk.java.net/16/
In the "Builds" section, click on the JDK version for your OS to start the download.
It's a good idea to move the downloaded archive to a safe place before unzipping it in order to be sure you don't accidentally delete it.
IMPORTANT! Be sure you don't have any Cyrillic characters in the path to the JDK. Cyrillic characters will cause problems with launching programs.
5. Video about installing the JDK
We made a special video that covers every possible questions about this process.
Of course, if you still have any questions, you can always ask them on our Forum.