Java Tutorial: Create Your First Hello World Program



In this article, you will be able to have a basic understanding of what Java is and how to install it to your computer. Once you have Java installed on your computer, you will then learn how to create your first Hello World program. 

What is Java?

Java is an object-oriented program language, and one of the most popular programming languages as it is very popular among the developers. On top of that, Java is used by 95% of the enterprises as their primary language. The popular programming language allows developers to compile Java code then run it on more than one operating system, such as Windows, Linux, macOS, etc. However, in order for this to occur, the developer must have a Java runtime environment installed. But the question is: How do you install Java on your computer?

Installing Java On Your Computer 

In this tutorial, you will learn how to download the Java Development Kit (JDK) on Windows, which is a development environment for building applications and components using the Java programming language. The JDK includes the compiler and class libraries, allowing developers to create Java programs executable by the Java Virtual Machine (JVM) and Java Runtime Environment (JRE).

Lets begin. 

First, you will need to check to see if Java is already installed on your computer. 
  1. Click on the start menu and type Command Prompt in the search bar and press Enter.
  2. Type the following command: java -version 

The command outputs this message if Java is not installed on your computer. Let now install Java now that we have confirmed it is not already on your system.

Downloading Java on Windows

  1. Download the latest release of the Java™ Platform, Standard Edition Development Kit (JDK™) by visiting Java Downloads | Oracle  
  2. Under the Windows tab, click on the x64 Installer download link. 


Once the x64 Installer has downloaded in your preferred browser, click to install Java onto your computer and allow the application to make changes to your computer to proceed with the installation.

The installation wizard for Java SE Development Kit will then pop up on your screen and guide you through the installation process. 

  1. Click on Next to proceed. 
  2. Continue to click Next if you would like the destination folder to stay as default or click change to change the path for the installation folder. 

  3. The wizard will finish the installation process and you will see a successfully installed screen. Click Close to exit the wizard. 

Now that you've download Java onto your computer, you can now create your first Hello Word program!

Create Your First Hello World Program

In this tutorial, we will be using IntelliJ as our IDE. Visit IntelliJ IDEA to install IntelliJ onto your computer to follow along. 

  1. Click on your start menu and type IntelliJ IDEA to launch the application. 
  2. Once launched, click on New Project 


  3.  Enter the name of the project as HelloWorld and leave the rest of the fields as default. Click Create

    Next we will create a package and class in this project. 

  4. In the project window, right click the src folder and click New and then Java Class

  5. In the Name field, type com.example.helloworld.HelloWorld and click OK.
    Note: com.example.helloworld will be created as the package and HelloWorld is the class in your project. 

Now we will write our code!

  1. After the first curly brace {, press Shift + Enter to add a new line. 
  2. Type main and select the template that inserts the main() method declaration.
  3. Now, add the following code: System.out.println("Hello World");
  4. Click the green arrow in the gutter to run your code. 
  5.  Lastly, your Java application should have print "Hello World" to the system output!
Congrats! You have created your first Java application. 

Resources 

I wanted to also share additional resources that I've found very useful for installing Java and creating your first Hello World application. The first link I would like to share that I found useful to learn how to properly install Java on my computer is Install Java - javatpoint and the resource I found useful to learn how to create your first Hello World application is Creating First Java Program in Eclipse IDE - Dot Net Tutorials. Lastly, w3School is great resource to utilize when you are just learning Java, here is the link for more Java tutorials Java Tutorial (w3schools.com).

References

GeeksforGeeks. (2019, January 6). Interesting Facts About Java. https://www.geeksforgeeks.org/interesting-facts-about-java/#:%7E:text=Here%20are%20some%20interesting%20facts%20about%20Java%3A%201,making%20this%20language%20more%20complex.%20More%20items. . .%20

Comments

Popular posts from this blog

Computers in the Workplace

Network Security

Tech Topic Connection: Database Management