Here we will see structure of java program and create a java first program in notepad and run it
1. Structure of Java Program
Lets see the basic structure of java program
1 2 3 4 5 6 7 | class className { //main method of java program public static void main(String args[]) { //program execution starts from main method } } |
Here:
class- is write to create a class.
class_name – is a name of class. It is a identifier.
public– is a access modifier is used for main() method accessible for every one.
static- class contain a main() method not have a object and if we want a access a class without create a object of that class then method main() must be declare as a static.
void- is a return type. Void denotes that main() method return noting.
main()– main is a method from where execution of program starts.
2. Syntax to print statement
1 | System.out.println(); |
Here:
System: System is a predefined class, it is a final class in java.lang package
out: is a static member of the System class, and is an instance of java.io.PrintStream
3. Simple java program to print Hello Students
Write java first program in notepad as given below
1 2 3 4 5 6 | class HelloStudents { public static void main(String args[]) { System.out.println("Hello Students"); } } |
4. How to run java program in cmd
1 Open notepad and type program open file then save this program with name HelloStudents.java.

2. Goto start menu and type ”cmd” and press enter to open command prompt.

3. Use the cd command ( cd dir_name or .. to go up one directory) to navigate to the directory where HelloStudents.java program is save.

For example: HelloStudents.java saved in a “document” folder of c directory.
c:>cd documents [press enter]

4. for compile write (with file name) : javac HelloStudents.java // here javac is a compiler

5. run write (with class name): java HelloStudents

Output
1 | Hello Students |