Here is the basic java program which will help java beginners.
In every programming language when we initially starts learning,
we always find the "Hello World" program in books.
So in java same program is the first step for you to start with.
Here is the sample "Hello World" Program:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
Please follow these steps to compile and execute this HelloWorld program.
- Open notepad or any type of text editor.
- Copy and paste above code into that text editor.
- Save that file and named it as "HelloWorld.java"
- Goto command prompt and compile this program using javac command
- c:\path\to\file\>javac HelloWorld.java
- This will generate a HelloWorld.class file
- Now for executing that class file you have to issue following java command
- c:\path\to\file\>java HelloWorld
- You will see Hello, World as the output.
I hope this post helped you in your learning. Please ask your questions by comments.
Dont SPAM