How to Create a Project in Eclipse

Last updated on - August 29th, 2018

One question that may come to your mind is why do we need to create a project to automate the application. Let’s understand the need for the project by reverse engineering approach. After that, we will explore how to create a project in Eclipse.

To have automation testing in place, you need to write an automation code. To write an automation code, you need a class in Java world. A class can only be created within a package, which is present inside Java project.

You need to create a project in your favorite integrated development environment (IDE) like Eclipse. The project provides you a structured way to manage all your code files and resources.

Let’s understand Java project structure in Eclipse using the image below.

create a project in eclipse

In this article, I will explain step by step details how to create Java project in Eclipse.

The whole process is very simple and straightforward. I will segregate it into four different parts.

1) Download and Launch Eclipse

2) Create a New Project

3) Create a New Package in the Project

4) Create a New Class Inside the Package

Download and Launch Eclipse

1). Download the latest Eclipse from Eclipse download link and start Eclipse IDE just by double click on eclipse icon (eclipse.exe on Windows OS).

2). Provide workspace folder name when asked while launching the Eclipse.

Workspace is nothing but the dedicated folder in your system (of your choice), where you will place your projects and automation artifacts. On selecting a workspace, Eclipse would recognize all the projects present in the workspace folder.

create project in eclipse

3). Once Eclipse is launched, you will see a welcome page.

Welcome page contains many useful links which you can refer to learn. For now, you can close this page and move ahead to create a project.

eclipse welcome page

Create a  New Project

1). To create a new project, navigate to File > New > Project. 

select project from file menu

2). This will open a new dialog where you can select the type of the project you want to create like Java Project, Maven Project etc.

Let’s select ‘Java Project’ as a part of this exercise and click on ‘Next’ button.

select java project in eclipse

3). Provide your project name ‘JavaProjectDemo’, select ‘execution environment (JRE)’ version and click on ‘Finish‘ button.

You can change JRE version as per your choice. Do not change it if you want to continue with the latest Java version installed on your system.

Mention project name in eclipse

4). Java project is created now and listed in ‘Package Explorer‘ in Eclipse.

created project in eclipse



Create a New Package

As per the Java standard project structure, you should create a package inside your project to segregate different types of files or resources.

If you will not create package explicitly, then eclipse will create a new package with default name automatically. However, it’s always good to create a package and provide an appropriate name.

Let’s understand how to create a package.

1). Right click on ‘src’ folder and select New > Package

create package in eclipse

2). Give package name ‘testCases‘ and click on ‘Finish‘.

enter package name in eclipse

3). You can see a new package under the ‘src’ folder as shown below.

created package in eclipse

Create a New Class

To write Java code, you need to create a class inside the package. Let’s see step by step details to create a new class in eclipse.

1). Right-click on a package that you have created in the previous section and select New > Class

create class in eclipse

2). Give class name ‘DemoTest‘, select option ‘public static void main‘ option and click on ‘Finish‘.

If you want to run pure Java code, you need to select ‘public static void main’ option. To run Selenium WebDriver program you don’t need the main program. So, select accordingly.

enter class name in eclipse

3). Now, your project structure looks like as shown below

created class in eclipse

Points to Note

Similar to the above steps, you can create as many packages and classes you want as per your requirement to categorize different test artifacts.

Now, your project is ready to run Java programs, as Java libraries (Jars) are by-default associated with your project in Eclipse under ‘JRE System Library [JavaSE-1.8]‘.

Next, you can configure Selenium WebDriver libraries to this project to enable the use of Selenium WebDriver APIs and start automating your application.

I hope this article helped you to understand how to create a project in Eclipse. Further, you can also read other related articles.

Let me know if you have any questions. Share your thoughts in the comment section.

Do you know someone who can benefit from the information in the article? Share it with them on Facebook, LinkedIn, Twitter or Google Plus.

For Further Reading :

About Suresh Dubey

I am Suresh Dubey working as an automation test engineer. I am passionate about playing with automation testing and tools. I got a chance to work on Selenium, UFT, PowerShell, Jenkins, CI-CD, Maven, Cucumber, Git etc. I believe in 'Knowledge Sharing'. My mantra for success is 'Learn Something New Everyday'.

View all posts by Suresh Dubey →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.