Fundamental Programming
Structure
Rajasekaran. S
Assistant Professor
Dept of IT
First Java Program
Say Hello to World
import java.io.*;
public class Main {
public static void main(String[] args){
System.out.println(“Hello World”);
}
}
Checking for Java and Javac
Check for Java Compiler and Java Interpreter is
properly installed on your system.
Open CMD Prompt
Type javac
If you prompt with option’s then javac is available.
Else you will be prompt with javac command not found jdk package not
installed and proceed with jdk installation.
Creating Folders for My Program
Open Notepad
Saving File as Main.java
Rule 1: File name must resemble class name.
Creating Your First Program
Compiling Main.java
javac Main.java
What is Main.class ?
Running Java Program
java Main
Live Demo
Linux
https://youtu.be/rrrWZXbMuUw
Windows
https://youtu.be/hpOkLHWe5DY
Java Comments
It is a programmer-readable
explanation or annotation in the source
code of a computer program.
It help’s to understand the source code.
It is ignored by compilers and
interpreters.
How to Comment in Java?
import java.io.*;
public class Main {
public static void main(String[] args){
//This will print hello world in console;
System.out.println(“Hello World”);
Single Line Comment
}
}
How to Comment in Java?
/*
*@author Rajasekaran S
*@version 1.0 Multi Line Comment
*Program Says hello to the world
*/
import java.io.*;
public class Main {
public static void main(String[] args){
//This will print hello world in console
System.out.println(“Hello World”);
}
} Single Line Comment
Thank You
Rajasekaran S
Assistant Professor
Dept of IT