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
- Click on the start menu and type Command Prompt in the search bar and press Enter.
- Type the following command: java -version
Downloading Java on Windows
- Download the latest release of the Java™ Platform, Standard Edition Development Kit (JDK™) by visiting Java Downloads | Oracle
- Under the Windows tab, click on the x64 Installer download link.
- Click on Next to proceed.
- 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.
- The wizard will finish the installation process and you will see a successfully installed screen. Click Close to exit the wizard.
Create Your First Hello World Program
- Click on your start menu and type IntelliJ IDEA to launch the application.
- Once launched, click on New Project
- 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.
- In the project window, right click the src folder and click New and then Java Class.
- In the Name field, typeNote: com.example.helloworld will be created as the package and HelloWorld is the class in your project.
com.example.helloworld.HelloWorldand click OK.
Now we will write our code!
- After the first curly brace {, press Shift + Enter to add a new line.
- Type main and select the template that inserts the
main()method declaration. - Now, add the following code: System.out.println("Hello World");
- Lastly, your Java application should have print "Hello World" to the system output!
Resources
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
Post a Comment