First Java Program

Get started with Java today. Download; Developer Resources; Help; Get Java for desktop applications lets start first java program

Writing First Java Program

  1. Open any editor (Notepad/Notepad++)
  2. Write Java Program
    1. Create Class
    2. Create main method
    3. Write code into main method
  3. Save Java Program with .java extension.
    1. File name must be same as public class name.
    2. File Extension must me .java
  4. To compile and run java code open CMD.
  5. Navigate CMD path to the location where you save your java file.
  6. Compile Java File
    1. To Convert High level language into Byte code(Machine Understanding language)
    2. Command to compile java file  javac FileName.java

7. After compilation of java code we will get a .class file

  1.   Run Java Program
  2.  Command to Run Java File  java className

In this way we should write java source code in Notepad.

 

Tips and Tricks

  1. Source File is a file which contains java code
  2. Source code is a java code
  3. Java Class can be compile even if we don’t create main Method.
  4. At execution time if main method not found the you will get an following error.

  1. One Source file can contains more than one java classes.
  2. But only one java class must be public, and file name must be same as public class.
  3. .class file creates for a class from the source file and not for .java file.
  4. For example if one source file has 3 java classes, then after compilation of that source file you will get an 3 .class files.
  5. Each java class for a source file can have main method.
  6. Each Java class can be run independently because they have their own .class file.
  7. 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

 

Share This Information To Your Friends and Your College Group’s, To Help Them !