Get started with Java today. Download; Developer Resources; Help; Get Java for desktop applications lets start first java program
Writing First Java Program
- Open any editor (Notepad/Notepad++)
- Write Java Program
- Create Class
- Create main method
- Write code into main method
- Save Java Program with .java extension.
- File name must be same as public class name.
- File Extension must me .java
- To compile and run java code open CMD.
- Navigate CMD path to the location where you save your java file.
- Compile Java File
- To Convert High level language into Byte code(Machine Understanding language)
- Command to compile java file javac FileName.java
7. After compilation of java code we will get a .class file
- Run Java Program
- Command to Run Java File java className
In this way we should write java source code in Notepad.
Tips and Tricks
- Source File is a file which contains java code
- Source code is a java code
- Java Class can be compile even if we don’t create main Method.
- At execution time if main method not found the you will get an following error.
- One Source file can contains more than one java classes.
- But only one java class must be public, and file name must be same as public class.
- .class file creates for a class from the source file and not for .java file.
- For example if one source file has 3 java classes, then after compilation of that source file you will get an 3 .class files.
- Each java class for a source file can have main method.
- Each Java class can be run independently because they have their own .class file.
- If public class name not match with the source file name, then you will get a following error
Join Telegram : Click Here
All Full Stack Java Study Material
Job’s For Fresher