1.Create new Java project.

Add Project Name on Create a Java Project tab. Click on finish button.

Create new java project

Now you’ve got project folder with 2 subfolders, src and JRE system library. We are going to code inside src ( source) folder.

2.Create a package inside the project.

A java package is a group of similar types of classes, interfaces, and sub-packages. Java package is used to categorize the classes and interfaces so that they can be easily maintained.

To create a package, Right click on src folder and select New >> Package from the drop down menu.Enter a name to package folder and click finish to create the package.

Create a package

You can see the package folder at your workspace which resides in the windows user folder. a Java package removes naming collision.

3. Create a class.

To understand the class, you’ve to know what is an object.An Object is an entity that has state and behavior is known as an object e.g. chair, pen, table, car etc. It can be physical or logical. The example of a logical object is banking system.

A class is a group of objects that has common properties. It is a template or blueprint from which objects are created.

To create a class inside your package, Right click on the package “FirstPackage” and navigate New >> Class on the drop down list.

On New Java Class window, Add a Class name and check “Public static void main” to create a method. A method is like function used to expose the behavior of an object.

Here class name is MyFirstClass. Once you were done, click Finish to create the class.

Create a class

You will see the package, class inside the package, and a method inside the class on java editor that we created. The main method in Java is a standard method which is used by JVM( Java Virtual Machine) to start execution of any Java program. So this method will compile at the beginning of the run.

MyFirstClass.java

Here, we are going to print Hello World on screen. The eighth line system.out.println() will print you the string inside the parenthesis. The compiler ignores everything from /* to */ and it ignores everything from // to the end of the line.

The compiler ignores everything from /* to */ and it ignores everything from // to the end of the line.

Anwar Yakkiparamban is the founder of Lauyou Learning. Prior to Lauyou learning, Anwar worked at ARD Engineering & Development, Qatar. He holds bachelor degree in Electronics and Communication Engineering from Govt. Engineering College Idukki.