Monday, September 4, 2017 2:21:14 PM

How To Create A Simple Java Program And Run It In Your Computer?

Ding Teck Song's picture

Good day everyone. In this article, I am  going to teach you how we can create a simple Java application and run in our own computer.


What is Java?

Before I actually get started, let us discuss something general first. Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that uses Java and they will not work unless you have Java installed in your computers. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!


Do I Need to Installed Java in My Computer?

After you read the above paragraph, you might ask a simple question which is do I need to install Java in my computer? The answer is yes. You need to have Java installed in your computers in order to develop and run Java programs. If you don’t have Java installed in your computer, simply visit this page to download and install Java in  your computers.


What Do I Need?

Another question that you might ask is what are the software tools that I need in order to develop a Java program? To develop a Java program, you need a tool call Java Development Kid (JDK) in your computer. You can easily download it from this page. Another tools that you need is a simple text editor to write your code. You can use the build-in notepad in your Microsoft Windows computers or use a text editor call Notepad++. You can get it from this page to write your code.


How to Get Started?

After you get all the tools that are needed to develop a Java Program, you might ask a question which is how I am going to start developing my first Java program? As about the first Java program, usually people will develop a simple program that simply display the text on the screen. The following code show you how it is done. Please note that all java programs should have a “.java” file extension. Therefore, copy the following code and paste it in your text editor and save the file as “” or download the “” from the link below.


public class HelloWorld {

               public static void main(String[] args) {

                              System.out.println("Hello World");




How To Run The Java Program?

Now we have a simple Java program that simply print out or display the text “Hello World” on the screen. Let’s run the program and see the output of the program. Follow the steps below to run the Java program:

  1. Open the Command line window by entering “cmd.exe” in your start menu and press enter.
  2. Navigate to your Java program directory and copy its path.
  3. Go back to your command line window and type “cd ” (which stand for change directory) and paste the path that you copied before. Once you done, press enter to execute the command.
  4. Next, navigate to the directory where your JDK located. And go in to the “bin” folder inside your JDK folder. Usually it is located at C:\Program Files (x86)\Java\jdk1.8.0_152\bin. Please note that “jdk1.8.0_152” is the version of your JDK. Therefore, your path might be different from me depending on which version of JDK that you install. Once you reach the folder, copy the path of your “bin” folder.
  5. Now, go back to your command line window once again and type “set path =” and paste the path of the “bin” folder that you copied earlier. Once you done, press enter to execute the command.
  6. Before you actually run the Java program, you have to compile it first. To compile the Java program, simply type “javac ” and continue with the file name of your Java program along with its file extension. Once you done press enter to execute the command.
  7. Finally, to run the Java program, simply type “java ” and continue with the file name of your Java program. Once you done press enter to execute the command. You are able to see the output of the program which is just simply display the word “Hello World” after you press enter. To exit from the command line window, simply press alt+f4 or type “exit” and press enter.


That’s all for now. Hope this article will be beneficial for you. Good luck and happy coding!