Saturday, 24 January 2015

How to Run Java Programs on Windows 8

public class HelloWorld { 
   public static void main(String[] args) { 
      System.out.println("Hello, World");

The above code is for the most basic Java program you can write. All it does is prints out Hello World to the screen.

In order to run the above program, you need to copy the code above and paste it to a file called

It is important that you name the file the exact name of your class otherwise you will get an error. Once you do that, save the file in a location you can easily access. I am saving it to my Documents directory.

Follow the following steps to run a Java program on your machine.

  1. Open your command window. This can be done by using Window + R on your machine.
  2. My window take me to my user directory. Use the cd Documents command to get to your documents directory.
  3. Once you are in the Documents directory, run the javac command.
  4. If nothing happens, your program is error free. I expect it to be since you are copying my code.
  5. Next run the command java HelloWorld you will see Hello, World on your command window as shown below
There you have it. You can now run Java programs on you machine. Why is this important? It is important because it means that you can use you machine to develop Java applications.

No comments:

Post a Comment