Writing Your First Java Program

In previous post we have installed and run the eclipse, now lets write first program.

Step1: Launch the Eclipse:

Step2: Select the workspace where you want to save the project.

eclipseworkspace

 

Step3: Create Java project:

Click on File > New > Other Projectprojectcreation1

now select the java project and click on next

projectcreation2

 

Enter project name and click on finish

projectcreation3

 

Now your project is successfully created.

Step 4: Create Package, Class and write first project

expand Project Explorer ( on left hand side) , Select Src folder > Right click on it >  New > Package

packagecreation

Enter the Package Name and click on finish button

now select the package which you have just created > Right click > New > Class

Enter the class name “HelloQeworks”

classcreation

 

class file gets created and following code automatically gets populated

package firstPackage;
public class HelloQeworks {
/**
 * @param args
 */
 public static void main(String[] args) {
 // TODO Auto-generated method stub
}
}

now inside method main, we will write print statement and run the program.

package firstPackage;
public class HelloQeworks {
/**
 * @param args
 */
 public static void main(String[] args) {
 // TODO Auto-generated method stub
 System.out.println("Hello Qeworks");
}
}

Now Save the file and execute the code.

firstprogram

on console you will get ” Hello qeworks” printed.

consoleprint

 

You have successfully created a your First Java Program

You might also like More from author

Loading...