JAVA LESSON 1 – JAVA DEVELOPMENT ENVIRONMENT INSTALLATION

 


INTRODUCTION

In today's free Java lesson, we will install Java 23 JDK along with all the necessary tools that will help us create new applications written in Java, debug existing Java code, and run our Java applications.

For this purpose, we will need to have the following tools available and installed on our computer:

  • Java Development Kit (JDK) 
  • Apache Maven
  • VS Studio Code

JAVA SE DEVELOPMENT KIT INSTALLATION

In the upcoming free Java lessons, we will use Java 23, which is the latest version at the time this free Java lesson is being written.

As a first step, we need to go to the Oracle website (JDK Development Kit 23.0.1 downloads) and find the Java version suitable for our computer's operating system. All of our examples will be created in a Windows 10 environment.

Once the file is downloaded, double-click on it to start the installation.

In the next step, we accept the suggested location, where the Java Development Kit will be installed on our computer, by clicking Next.

Wait a few seconds for the Java installation to complete, and then click Close to exit the installation window.


 

Although the Java installation process has been completed, the Java JDK is not officially registered in the Windows environment yet. Programs such as Apache Maven and VS Code (which we will install right after this step) that require Java to function properly will look for the officially declared Java version in the Windows environment. If Windows doesn't know exactly the path where Java has been installed, our programs won't be executed.

For this reason, we need to go to the System Settings in Windows and declare the installation location of the Java that we just completed.

Inside the windows search area, search for View advanced system settings.

From the tabs that appear, click on the one that says Advanced, and then click on Environment Variables.

In the new window that appears, click on the New button in the System Variables section.

 

Here, we define a variable named JAVA_HOME and set its value to the location where Java has been installed. Click OK when you complete this step.

 

 
Now, we need to declare the location of the Java executable file in the Path variable. So, double-click on the Path variable to display its settings.
 

Click on New and then navigate the Windows to the bin folder of the Java installation. Once you've completed the declaration, click OK.

Now, open a CMD terminal in Windows and run the command java --version to ensure that Windows has correctly recognized the settings you added in the previous steps. The output of the command should look like this:

APACHE MAVEN INSTALLATION

The next important program we need to install is Apache Maven. This tool will help us create an initial Java project and automatically load all the libraries required for our application to run correctly. Apache Maven is an essential tool for every Java developer, and you will need it both for the upcoming free Java lessons and for the free Spring Boot lessons that will follow in the future.

So, we go to the Apache Maven website (Maven – Download Apache Maven) and download the latest version in zip format (Binary zip archive).

After downloading the file, unzip it to any directory you prefer.

Now, we need to declare the location of the Maven executable to the Windows (just like we did with Java in the previous step) so that programs like VS Code can find it and use it to create new Java projects. The first step is to create a new variable named M2_HOME and set its value to the folder where Apache Maven is located.

 

 

The second step is to double-click on the Path variable and declare the bin folder where the Apache Maven executable file is located.

If we now open a CMD terminal and run the command mvn --version, we should see the version of Apache Maven that we have installed, along with the version of Java it is using.

VS CODE INSTALLATION

 Now that we have installed Java and Apache Maven, we can choose any Integrated Development Environment (IDE) that suits us to develop our Java applications. There is a fairly large list of free and reliable IDEs you could choose from, such as IntelliJ Community Edition, Eclipse, NetBeans, and others.

In the free Java lessons, we will choose Visual Studio Code because, quite simply, it has many free extensions, supports all programming languages, and offers a wide range of services. Of course, the choice is yours, and you are welcome to follow the lessons using any IDE of your choice.

Our final step is to install Visual Studio Code. This will be an easy process because we simply download the program from the Microsoft website (Visual Studio Code - Code Editing. Redefined) and proceed with the easy installation process.

As we mentioned earlier, VS Code is an environment that supports multiple programming languages. However, we need to install the extensions corresponding to the programming language we want to use. In our case, we need to add the Java extensions to the VS Code environment so that we have access to all the features that allow us to write, run, and debug our programs.

So, we start VS Code and, from the icons on the left, select the Extensions view. In the search field, type Java to display the list of all available Java extensions. Click on Extension Pack for Java and, on the right side, select Install. This specific extension will actually trigger the installation of a collection of other extensions whose features are essential for any Java code.

Following the same exact logic and process, we can install any other extensions we think might be useful. For example, you can search for an extension that automatically generates getter and setter methods in a class. Of course, anything else we may need will be covered in future Java lessons.

Our environment is now all set up. In the next free java lesson, we will show step-by-step how to create a simple Java program, how to compile it using Maven, and how to run it.

Don't forget to make a small donation so that this blog can grow even more and offer more capabilities for delivering free lessons online.

full-width

Post a Comment

1 Comments

  1. Μπράβο σας. Ίσως ο καλύτερος οδηγός για το πως να στήσεις το λειτουργικό σου για java development που έχω δει!

    ReplyDelete

What do you think about Ground of Code?