Wikia

Scratchpad

Your First Java Program

217,804pages on
this wiki
Discuss this page1


Your First Java Program

Here you will learn how to create your first Java program that will print the text

    "Hello World"

Create the following file in a text editor, such as notepad. Do not use an office text editor, such as word.

Add the following text to your file:

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


Don't worry what this means, we'll go over it later.

Make sure that a Java complier is installed on your PC.

Save this as "first.txt", open a command prompt, and type

     javac first.java

Then type

     java first

With any luck, you will see the following text:

    Hello World.

Congratulations!

Around Wikia's network

Random wikia