Lesson 1 – Environment Setup and Getting Started Copy

In this lesson, you will see how to set up the environment that you will be using to run Java application. Once the environment is setup, you will see how to learn your first program in Java.

Environment Setup

You need to install Java environment in order to run Java applications. The Java environment consists of two parts: Java Development Kit (JDK) and Java Runtime Environment (JRE). The JDK is required in order to develop Java Applications while JRE is required to run the application.  There are several options to install Java environment. However, we will take the easiest route. We will install Eclipse IDE which has its own JDK and JRE.

Installing Eclipse on Windows

To download Eclipse for windows, go to the Eclipse Download Page and click the download button. Depending upon your system architecture, a 32 or 64 bit executable installer file will be downloaded to your system. Run the executable file. You will see the following options:


From the above options, select the first option i.e. “Eclipse IDE for Java Developers”. You will see the following window:

Click on the “Install” button and accept the license agreement. The installer will start installer Eclipse into your machine at default location. It may take some time, so sit back, relax and have a cup of coffee.

Once the setup is complete, you should see the following window:

Click on the “Launch” button. Your Eclipse IDE will be launched. It will ask you for the path to your workspace. The workspace is the directory on your system where your Java projects will be stored by default. You can specify any custom location for your workspace or select the default workspace location and click the “Launch” button again. You should see the following screen:

Congratulations if you have seen the above screen. You have successfully installed Eclipse on Windows.

Installing Eclipse on Linux

The process of installing Eclipse via Software Center of any Linux distribution is straight forward. You simply have to search “Eclipse” on the Software Center search bar and click the “Install” button as shown below: The rest of the process is same as windows.

Else, if you want to install Eclipse on Linux via command line, here is a good blog on how to install the latest Eclipse on Ubuntu.

Running your First Program


Let’s now run our first program. By default, the Eclipse IDE is installed at “C:Usersuser_nameeclipsejava-2019-06eclipse”. Here “user_name” is the name of your PC. Open Eclipse, from the top menu, click on “File -> New -> Project”. You should see the following window:

In the “Project name” field, enter your project name. You can give any name. I gave it the name “MyProgram”. Click on the “Next” button. You will be presented with the project settings. The project window looks like this:


Right click on the “Src” folder. Click “New->Class”. You will see the following window:


In the name field, enter any class name. I entered “MainClass”. Also, check the “public static void main(String[]args)” checkbox. I will explain what it does in the next section. Click on the finish button. The class file “MainClass.java” will be opened. The default script of the file looks like this:

public class MainClass {

public static void main(String[] args) {
// TODO Auto-generated method stub



Let’s see what is happening in the above script. Java is an object oriented language which means that everything happens inside a class in Java. The first line of the script creates a class named “MainClass”. When the Java application starts, the Java runtime looks for a function or method called “public static void main”. This is the starting point of the Java code. We will see functions in detail in an upcoming section. To run the above script, simply click on the green triangle from the top menu as shown in the following image:

You will see that nothing will be displayed. This is because, there is nothing inside our code. Let’s now write a simple statement inside our code that prints “Welcome to Java” on the console.

public class MainClass {

public static void main(String[] args) {
// TODO Auto-generated method stub

System.out.println("Welcome to Java");



Once you run the above script, you will see the statement “Welcome to Java” printed on the Eclipse console window. Here we used the “println” method from the “System.out” class. The print method actually prints anything passed to it in the form of text.

What’s Next?

In this lesson we saw how to setup the Java environment and how to run first program in Java. In the next lesson we will see different data types.