How to use the Eclipse IDE for Java Application Development

How to use the Eclipse IDE for Java Application Development
Spring 2016/2017
Computer Science Department
TA Rena Alzaid
How to use the Eclipse IDE for Java Application Development
1. Download and install Java JDK. Make sure to choose the appropriate link for
your computer. (
2. Download Eclipse Neon.2 (4.6.2) Development Environment. Make sure to
choose the appropriate eclipse program link for your computer system.
3. Run the eclipseinstaller by running the .exe file you downloaded in step 2.
Choose Eclipse IDE for Java Developers then choose the installation folder you
would like the program to be stored in and click INSTALL. Continue the
installation process. The program will be installed on your system.
4. Create a folder on your desktop named MyWorkSpace. This folder will store all
of your Java projects.
1. The first time you start Eclipse, it will ask you to specify a default workspace. This is
where files are created for you. You need to remember this so that you can find your
files to submit. Choose the MyWorkSpace folder you created in step 4 of the prework as your default workspace by clicking on Browse and selecting the folder
MyWorkSpace from your desktop.
Click Browse to
choose the location
of your default
Click to use the same
folder each time
eclipse is started
2. Eclipse then comes up with a Welcome screen. This screen provides information for
new users, examples and tutorials. Click on the “Workbench” arrow icon, which will
start the workbench portion of eclipse. After that you will see the Eclipse main
window, also called the workbench.
Go to the workbench
This is the startup screen with no projects or files active.
Drop down menus for various functions. You
can also use the icons once a project is created
Icons can be
used in place
of menu items
This will be the editor window
Either the menu items listed across the top of the screen or the icons can be used to:
Create projects
Create classes
Execute them.
Since no projects currently exist, most of the icons on the toolbar are greyed out.
3. Eclipse is a project oriented integrated development environment (IDE). In other
words, you must create a project in order to run your files. Each Java program we
will write will be stored in its own project. From the Eclipse menu bar at the top of
the screen, choose
File > New > Java Project…
You can also choose
Java Project
from the small arrow at this icon.
This opens the New Java Project dialog box. In this box, you should enter a unique
project name (i.e. you cannot have two projects with the same name).
You should type a unique name
here for the project you are
Make sure to check this box so
your files will be stored in a
separate folder located in your
default folder.
The project
folder will have the same
project name you chose.
Use default JRE
should be chosen here to make
sure it uses the JRE you recently
This should be chosen to store all
the files for the project in one
folder. This is better to use when
trying to find your files quickly for
submission since they will all be
stored in one location.
Click Finish to continue with
the next step
This should be chosen to store the
program files for the project in
separate folders. This is better to
use if you prefer to organize your
files. Your source files will be
located in the folder src.
4. To add files already stored, go to step # 8, otherwise continue reading:
After creating the project, you will see the screen below. More of the icons are
now available. You now need to Create a class. The class will contain your
application. There is more than one way to do this. First make sure the name of
the project folder is highlighted in the Package Explorer tab (located on the left
hand side of the screen) then do one of the following to create the class:
a) File > New > Class
b) Right click the project folder from under the Package Explorer tab located on
the left hand side of the screen, choose New > Class
c) Use the New Class icon.
Choose File > New > Class
From the menu
Or choose the New Class icon
Or right click the project folder and choose
New > Class
5. Now a New Java Class dialog box will appear. You will need to provide the
The file name. The name should
be the same name as the class.
Leave empty
Should be public
Click Finish to create the new
Check this box if
your class
requires a main
The file containing the class you created. The file name is the
same name as the class and has the “.java” extension
Edit pane
Problems pane. The compiler will list syntax errors here. You can click on the error message
and the edit window will move the cursor to that point.
6. Having created the Java class, the window will change to the above. The edit pane
will have a predefined class and main entry point.
Within the Eclipse edit pane, please replace the following Java source code line
// TODO Auto-generated method stub
System.out.println("Hello World!");
If you make any syntax errors, you will see a red X appear to the left of the line with
the error. Hover over the X with the mouse to get more information about the error if
you need help. For example, if you leave the semicolon ( ; ) out from the code above,
you will see something like this:
Error position
Hover over the X to get
more information about
the error
Note: All errors must be fixed before you can run the class. The error indication will
disappear once the error is fixed
7. Periodically save your work using File > Save from the menu or by clicking on the
floppy disk icon.
Eclipse will automatically compile the source code when you save the file and any
syntax errors will be noted in the Problems pane.
Error in the program. Click on the error to go to the
line containing the error. Fix all the errors to be able
to run the program
Note: If your Java program requires more than one class, you can add additional classes
to your project by repeating the instructions starting from step 5. Make sure only one of
the classes contains a main method if your project contains more than one class! When
you are ready to run your program, continue with the step 10.
8. If you are creating a project using Java files that are already stored in a folder for
you, right click the project name and choose import.
Click import to add
files already stored.
Choose File System from the
General folder in the import
dialog box
Click Next
Click Browse to choose the folder
location containing your files
After selecting your
folder, click OK.
Place checks on the files you
wish to add to your project
Click Finish once you are
Another, easier way to do this is to drag and drop the file into the (default package)
of the project you wish to add the file to.
If your program has no syntax errors, you can run your program as follows:
Highlight the Java file that has the main
method in it.
Run > Run As > Java Application
10 | P a g e
Or you can right click the file, then
Run As > Java Application
Or you can click the Run icon
11 | P a g e
The output of your program will be displayed in the
Console pane.
10. You can remove files from a project by right clicking on the file and choosing
Delete. The same can be done to remove projects from the workspace.
Written by TA Rena Alzaid
12 | P a g e
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF