Java Basics

Learn to Use Java
Open Notepad

Enter the Code

In writing a java program, it always begin with public class _________(Enter the name of your Program)
Then Write the code provided
public class Sample
{ public static void main(String args[])
{
System.out.println("Hi...This is my First Java Program");
}
}
It is necessary that you should all the things given above or simply copy them
Saving It

When you are going to save a java program, it is necessary to write the same name which you have written in the class name with a '.java' extension
Running a Program

Then you have to open cmd
For opening cmd just type it in the search box and do the following steps
- Navigate to the place where you saved your program in cmd
- Then type 'set path=C:\Program Files\Java\jdk1.8.0_101\bin' but change the version according to your jdk.
- Press Enter
- Then type 'javac'
- Then type 'javac Sample.java' Where I have type Sample.java you have to replace it with your file name
- If any errors were there then it would be shown on the screen.
- After correcting those errors do the 5th step again.
- Type 'java Sample' Where I have type Sample you have to replace it with your file name.
- Your program is ready
Important Points
- Your class name should start with a capital letter
- While typing your message, you should add inverted commas or it will show errors
- After typing your message, add a colon (;).