TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Eclipse Tutorials

Hello World using Eclipse IDE

Eclipse Tutorials

Introduction

In this article, we would go through the basics of working with Eclipse IDE. At the end of this post, you should be able to run a simple java program using Eclipse. We assume that you have Java and Eclipse installed on your machine. We will create a Java project and a Java class that will print “Hello world!” .

A common way to test something new is to create a simple “Hello World” program with the language or tools we are learning. So, let’s get started!

Eclipse Download: https://www.testingdocs.com/downloading-and-extracting-eclipse-ide/

Flowchart

 

Java Hello World

Create a New Project

We need a create a java project. In the main toolbar, click on the New -> Java Project button. The below picture shows how to create a new project.

 

JavaProject

Enter the project name Sample for the project name in the dialog box, then click Finish. However, you may choose any name of your choice. Attached below screenshot for your reference.

 

SampleProject

 

New  Java class

The next step is to create a new class. In the main toolbar, click on the New Java Class button. Enter “HelloWorld” for the class name, select the checkbox to create the main() method, then click Finish. The main() method would be created for you by checking this option in the dialog box.

It’s encouraged to specify the package for your class. We have specified “com.sample.demo” as shown in the below screen.In simple terms, packages are folders that hold java classes for better organizing and to avoid naming conflicts. You cannot have “HelloWorld” class twice in the same package  “com.sample.demo”. However, you can have  “HelloWorld” class in a different package let say “com.sample.practice”.

 

JavaClass

Hello World Java Application

The created class would look something like the below snippet :

package com.sample.demo;

public class HelloWorld {

 public static void main(String[] args) {
 // TODO Auto-generated method stub

 }
}

 

Now that you have your class, in the main() method, add the following statement to print “Hello World!” on the console. Then save your changes File -> Save or by a combination of keys Ctrl + S

System.out.println("Hello world!");

The complete program is now :

package com.sample.demo;

public class HelloWorld {

 public static void main(String[] args) {
 // TODO Auto-generated method stub
 System.out.println("Hello world!");
 }

}

// TODO Auto-generated method stub

The above line in the program is a single-line comment auto-generated and doesn’t interfere with the program. Comments add more readability to the programs.

To run your application, right-click on your class in the Package Explorer and select Run As > Java Application. The Console view should appear at the bottom and display the “Hello, world!” output.

 

Run the Application

After the java application run, you would see the console output that displays “Hello World!”.

 

Eclipse HelloWorld

Console output

To enable the console window in the eclipse,  go to the main toolbar Windows –> Show View –> Console.

Hooray! You have successfully created a Hello World Java application!

—

Eclipse Tutorials

Eclipse Tutorials on this website can be found at:
https://www.testingdocs.com/eclipse-tutorials

For more details on the Eclipse IDE, visit the official website at:
https://www.eclipse.org

Related Posts

Download Eclipse Installer

Eclipse Tutorials /

Install Eclipse using Installer on Windows 10

Eclipse Tutorials /

Eclipse Che Overview

Add Eclipse SpotBugs Install URL

Eclipse Tutorials /

Install SpotBugs Eclipse Plugin

Eclipse File Import

Eclipse Tutorials /

Import Maven Project in Eclipse

Eclipse marketplace online catalog

Eclipse Tutorials /

Eclipse Marketplace

‹ Install Eclipse on Ubuntu Linux› Getting familiar with Eclipse IDE

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version