To begin any programming language and understand it’s syntax we always start with
writing a simple program to print “HelloWorld”. For this we will need a text
editor such as notepad,wordpad. Java is a case sensitive language so be careful while
writing the program.
Ex- hello!=(not equal to)HELLO
Write the following code on your editor.
public static void main(string args)
Compiling Java Program
Save file with .java extension and remember the location. ex-C:\Users:\MyDocuments
The file name should be match the class name e.g. Print.java.
Open the command prompt to compile the Print.java program.
Go to the directory where you have saved the file ( in our case C:\Users:\MyDocuments)
and write the following command to compile the program.
javac is a compiler in the java Language. If u get the message:
‘javac’ is not recognized as an internal or external command,
operable program or batch file.
It means that java compiler could not be found and you have to set the path for it.
Path setting is explained in detail in the previous tutorial.
Running Java Program
If it is compiled without any error then to run the program issue the following command on command prompt:
You will see the following result on the command prompt.