How to write first Java program in Eclipse?

How to write first Java program in Eclipse?


Posted in : Core Java Posted on : July 21, 2014 at 5:45 PM Comments : [ 0 ]

This video tutorial is explaining the you the steps to create First Java Program in Eclipse. You will learn learn how to write and run the Java Program in the Eclipse software development tool.

Video tutorial on "How to write first Java program in Eclipse?" describes the steps to create and run First Java application in Eclipse

In the previous session we have explained Writing first Java Program and run it in console?, Now we will explain you how to create a project in Eclipse and then run your first "Hello World" example in the IDE.

Eclipse IDE is very useful for development of the applications, this tutorial will be your first step towards using the Eclipse software development tool. First we will create a project, create Java class, write code and then run the example in the Eclipse.

In the example described here we will explains you how to print the message on console, program also teaches you how to write a method for calculating the sum of the two numbers.

The video tutorial of this example explains you all the steps necessary to make the project and run the example. In a nutshell the steps to create project with Eclipse are:

  • Open Eclipse IDE
  • Create a new project
  • Add new file
  • Add code
  • Run the example

Here is the video of this tutorial:

Step to create project and run example in Eclipse:

Step 1: Create a new project

First of all start the Eclipse and then create a new project as shown below:

Creating First Java Project in Eclipse

The Eclipse IDE will create a project for you. You can see the complete detail in the video of this tutorial.

Step 2: Create the Java file as shown below:

Creating First Java Project in Eclipse

The name of the project is FirstExample and you can place the code in any package. In this example we have places this in the com.devmanuals package.

Step 3: Add the following source code into the file (FirstExample.java):

package com.devmanuals;

public class FirstExample {

	public static void main(String[] args) {
		System.out.println("Welcome to devmanuals.com");
		
		sayHello();
		
		int s = sum(2,8);
		
		System.out.println("Calculated is Sum:" +s);

	}
	
	public static void sayHello(){
		
		System.out.println("Hi, welcome to Java Programming...");
	}
	
	/*
	public static void sum(int i, int j){
		int k = i+j;
		System.out.println("Sum:" +k);
	}*/
	
	public static int sum(int i, int j){
		int k = i+j;
		return k;
	}	

}

Here is the screen shot from the Eclipse project:

Creating First Java Project in Eclipse

Step 4: Run the example code

Now right click on the source code window and then select "Run as Java application" to

Creating First Java Project in Eclipse

In this tutorial you have leaned how to create your first application in the Eclipse IDE. Check more tutorials at our Java Tutorials section.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics