Compiler, IDE, JDK and JVM in Java: This is what you need to start programming in Java


Keywords: Compiler, IDE, JDK, JVM, Bytecode, IntelliJ, Eclipse

Compiler IDE JDK JVM Java

This article covers basic concepts such as compiler, IDE, JDK and JVM that we need to get started with programming in Java.

What tools do I need to start programming in Java?

To program in Java, you first need to set up a programming environment that we can code in. This article covers how to set up this environment through four basic concepts that you need to know when programming in Java.

  • JDK (Java Development Kit)
  • IDE (Integrated Development Environment)
  • Compiler
  • JVM (Java Virtual Machine)

Java is platform-independent

A significant advantage of Java is that it is platform-independent, which means that you can run Java on all operating systems such as Mac, Windows or Linux.  Therefore, it is just as easy to program on a Mac (OS X) as on a Windows or Linux. An even bigger advantage is, it’s free! Anyone with a computer and an internet connection can thus start programming by downloading a couple of programs. But first, let’s sort out the four concepts.

What is Java Development Kit (JDK)?

To get started with Java programming, you first need to download a JDK (Java Development Kit). JDK is the development environment that enables you to develop applications and applications built in Java. The JDK contains, among other things, class libraries that facilitate programming but also includes a compiler that translates your code into machine code (more about the compiler later). Furthermore, the JDK also contains a JVM (Java Virtual Machine) that executes (runs) your program (more about JVM below).

How do I download the JDK?

The Java Development Kit (JDK) is available for free to download on Oracle’s website. You must download the version that is compatible with your operating system. The available versions are given under the heading Product / File Description. Download the JDK and follow the installation steps for your operating system.

Summary: What is JDK?

A Java Development Kit (JDK) is:

  • Necessary to code in Java.
  • Contains class libraries and tools that enable the development of applications and programs in Java.
  • Has a built-in compiler, that is, a program that translates program code to byte-code.
  • Contains a JVM (Java Virtual Machine) that executes (runs) your program.

What is a compiler?

When programming in Java, you also need a compiler. The compiler comes pre-installed with the JDK. The compiler translates your programming code into the computer’s internal language (machine code). A computer only understands ones and zeros, so the compiler starts by evaluating your code to see if contain any syntax errors and is written correctly. After that, the compiler translates your Java code into so-called byte files (class files). We can then run these class files in a virtual machine (JVM). This considerably simplifies, because you do not have to worry about how the computer will interpret your code. The compiler enables coding at a higher level, as we can write code that is more readable by humans, then the compiler handles the translation to the computer.

A compiler is a program that translates program code into the computer’s internal language. Hence, facilitating our work so we can write code more efficiently, without thinking that the computer should understand what we intend.

Summary: Compiler in Java

The compiler in Java:

  • Evaluates your code to see if contain any syntax errors and is written correctly
  • Translates your Java code into so-called byte files (class files)
  • Is a part of the Java Development Kit (JDK).
  • Enables high-level programming.

What is an IDE (Integrated Development Environment)?

When we are programming, we need a program to write the code in. This program is often called an IDE (Integrated Development Environment). Today, smart IDEs give us suggestions and find syntax errors for us directly when we code. Furthermore, there are several different IDEs that you can use, and it’s all about your preferences the one you end up using.

The two IDEs we recommend are IntelliJ or Eclipse. Here at code-knowledge.com, we have chosen to use IntelliJ, but both software is generally similar. However, when we show examples in future articles, we will start from IntelliJ. The version we use is the community version of IntelliJ which can be downloaded from the JetBrains website.

How do I download IntelliJ?

You can download IntelliJ from the JetBrains website and then just follow the installation instructions. Remember to select the operating system (Windows, Mac or Linux) you are using and make sure your computer fulfils the system requirements.  

Download IntelliJ from JetBrain

IntelliJ is available in two editions, the IntelliJ Community Edition is free and open-source that provides all the basic features for JVM and Android development, and the IntelliJ IDEA Ultimate that is commercial, distributed with a 30-day trial period. It provides additional tools and features for web and enterprise development.

IntelliJ IDE Java

Image 1: Logo IntelliJ

How do I download Eclipse?

Similarly to IntelliJ, download Eclipse from the Eclipse foundations website, select the operating system you are running, make sure your computer meets the system requirements, and follow the installation instructions.

Download Eclipse

Eclipse Java IDE

Image 2: Logo Eclipse

Summary: IDE in Java

The Integrated Development Environment (IDE):

  • Provides the programmer with an environment in which we can write and test their codes.
  • Finds syntax errors and gives suggestions when we program.
  • With the help of the IDE, we can run our programs.

What is a Java Virtual Machine (JVM)?

As the name suggests, JVM (Java Virtual Machine) is a virtual machine that enables a computer to run Java programs and programs written in other languages that are also compiled to Java bytecode. Once the compiler has created the class files of your Java code, these can be read by a JVM. This makes Java so powerful because Java applications can run on any operating system, as long as the operating system has a JVM (known as the “Write once, run anywhere” principle).

Summary: Java Virtual Machine (JVM)

JVM (Java Virtual Machine) is:

  • A virtual machine.
  • Can execute (run) bytecode in Java.
  • Can be performed on any operating system.

Summary: Compiler, IDE, JDK and JVM in Java

We now have gotten an overview of what we need to program in Java. Once you have written your Java code in an IDE, it is translated into machine code (in Java called bytecode or class files). These class files can be read by a virtual machine (JVM) that translates the bytecode so that all the various operating system can run your Java application.  

Flöde för att köra program skrivna i Java.  När du har skrivit din Java-kod i ett IDE, översätts den till maskinkod (I Java kallat för bytefiler eller klassfiler). Dessa klassfiler kan avläsas av en virtuell maskin som översätter bytefilerna så att varje enskilt operativsystem kan köra din Java-applikation.

On the next page, we will look at how you can get started with IntelliJ and create your first program.

Frequently asked questions: Compiler, IDE, JDK and JVM in Java

What do I need to start programming in Java?

To start programming in Java, you need a JDK (Java Development Kit) that contains a compiler and JVM that translates and runs the code. To make it easier when writing your code, you should also use an IDE (integrated development environment), such as Eclipse or IntelliJ.

Is it free to code in Java?

Yes. You need a computer and internet connection, then you can download the JDK for free on Oracle’s website.

What are IntelliJ and Eclipse?

IntelliJ and Eclipse are two different IDEs, i.e. integrated development environments that can be used to write code in Java. Note that there are many different IDEs and which one you choose is about depending on your preferences.

What are binary files?

A binary file also called a byte code, or class file is the code that the compiler creates when interpreting your java code. The computer only understands ones and zeros and to understand your java code, the computer needs to translate the code into something that the computer can understand. We call this binary files.

What is a JVM in Java?

JVM (Java Virtual Machine) is a virtual machine that can execute bytecode.