E03- First Java Program complied

In this session, we will write our first program. Follow the below steps to do it by yourself,

  1. Open notepad. Type the below program as seen in below picture with the following details,

UntitledIn the first line it says public class Hello, note that Hello name is same as per the file name. Our file name is Hello.java.  We use Curly brackets to write our main & statements

Now that we have declared our class we have to write the main & string which will have our statements.

In our statement we will write the method which our class will work on. In the statement, we want to print First Program in the machine by using our java file. So, we type System.out.Println where {Println is print line). Use small & inverted commas to display First Program.

Now, save the file in a new folder (name the folder as java/class) and save the file name as Hello.java .

2. As you can see below, my file is saved as  Hello.java ,



3. Now, open cmd by click window & search & type cmd. Go to the same folder where you saved the file Hello.java, copy the directory of this folder and in cmd type

cd & paste the directory by pressing (Ctrl+V) and press enter as shown below,


It changed the directory of your command prompt,

4. Now, type javac Hello.java & press enter, it will automatically enter in to new line which will create a class file in the same folder where you save Hello.java file.



5. Now, we will read this complied class file. In the same cmd, type java Hello and press enter,


As you can see above, what we wrote in our Hello.java file it is displaying in cmd. This was our test program. We will go together in this learning & let us see where it takes us.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s