How To Write Java Program Using Integrated Development Environment (IDE) ? of 14
How To Write Java Program Using Integrated Development Environment (IDE) ? of 14
Environment (IDE)
What is Eclipse?
The Eclipse IDE has a very long development history. In November 2001, IBM created the Eclipse
Project to implement a Java-based IDE that supports development of embedded Java applications. The
initial version of Eclipse derives from Visual Age - a multi-programming language IDE from IBM.
Originally created for developing a Java IDE, the Eclipse Foundation is now developing a wide range of
development tools that support many programming languages: C/C++, PHP, Javascript, Python, Rust…
However Eclipse is best known as the most widely used IDE for Java development.
Because the Eclipse Foundation releases many packages for different programming languages and
different domains, in this course the name Eclipse or Eclipse IDE refers to the package Eclipse IDE for
Java EE Developers. And as Java programmer, you use this package most of the time.
Eclipse is free and open-source, which means you can use it at no cost and access its source code if
needed. Today, Eclipse is the most widely used IDE for developing Java applications, with millions of
programmers using every day. The homepage of Eclipse is eclipse.org.
Versions of Eclipse
Eclipse has a long history of development so it has been evolving over many versions. Eclipse uses
interesting naming for its versions, mostly based on astronomy scheme: Juno, Kepler, Luna, Mars, Neon,
Oxygen, Photon…and the latest version uses different naming scheme, i.e. month-year format: Eclipse
2018-09.
If you are new to Java programming and Eclipse IDE, this step-by-step tutorial helps you get started to be
familiar with the most Java IDE by writing your first Java program using Eclipse. And you will be able to
build and run your program inside Eclipse.
1. Download and Install Eclipse IDE
Eclipse is the most popular Integrated Development Environment (IDE) for developing Java applications. It
is robust, feature-rich, easy-to-use and powerful IDE which is the #1 choice of almost Java programmers in
the world. And it is totally FREE.
As of now (fall 2016), the latest release of Eclipse is Neon (version 4.6). Click the following link to download
Eclipse:
http://www.eclipse.org/downloads/eclipse-packages
You will see the download page like this:
You can install Eclipse either by downloading the Eclipse Installer or package (zip file). I’d recommend you
to download by package. Eclipse comes with various packages for different development purposes. For
Java, there are two main packages listed as you see above:
Applications Development and Emerging Technologies Page 3 of 14
How to write Java Program Using Integrated Development Environment(IDE)?
Eclipse IDE for Java EE Developers: This is for developing Java EE applications (web applications
using Servlets & JSP).
Eclipse IDE for Java Developers: This is for developing Java SE applications, a subset of the Java
EE Developer package.
Click on the link 32-bit or 64-bit (depending on the bit version of your operating system) to start download
the package.
Eclipse Neon requires Java 8 or newer so make sure you have JDK 8 already installed on your computer. If
not, follow this tutorial to install JDK.
Click eclipse.exe file (Windows) to start the IDE. You will see the splash screen of Eclipse Neo:
That’s it! You have successfully installed Eclipse IDE. Next, let’s see how to create a workspace.
Check Use this as the default and do not ask again if you don’t want to be asked whenever you start
Eclipse. You can always change workspace when Eclipse is running.
Here we choose Java perspective. Click OK. Here’s how the Java perspective would look like:
In the New Java Package dialog, enter the name your package. Here I enter net.codejava:
Now, it’s time to create a Java class for your hello world application.
5. Write Your First Java Program
To create a new Java class under a specified package, right click on the package and select New >
Class from the context menu:
Applications Development and Emerging Technologies Page 8 of 14
How to write Java Program Using Integrated Development Environment(IDE)?
The New Java Class dialog appears, type the name of class as HelloWorld and choose the option to
generate the main() method:
Now, type some code in the main() method to print the message “Hello World” to the console:
That’s it. We have created a Java hello world program using Eclipse IDE.
6. Compile, Build and Run Your First Java Program
By default, Eclipse compiles the code automatically as you type. And it will report compile errors in
the Problems view at the bottom like this:
If you want to disable automatically build feature, click the menu Project and uncheck Build Automatically:
However, it’s strongly recommended to keep the auto build mode for it helps you detect errors instantly.
Now, let’s run the hello world application. Click menu Run > Run (or press Ctrl + F11), Eclipse will execute
the application and show the output in the Console view:
Applications Development and Emerging Technologies Page 10 of 14
How to write Java Program Using Integrated Development Environment(IDE)?
That’s it! The HelloWorld program has run and printed the output “Hello World” and terminates.
An eclipse perspective is the name given to an initial collection and arrangement of views and an editor
area. The default perspective is called java. An eclipse window can have multiple perspectives open in it
but only one perspective can be active at any point of time. A user can switch between open perspectives
or open a new perspective. A perspective controls what appears in some menus and tool bars.
Applications Development and Emerging Technologies Page 11 of 14
How to write Java Program Using Integrated Development Environment(IDE)?
File menu
Edit menu
Navigate menu
Search menu
Project menu
Run menu
Window menu
Help menu
File
1 The File menu allows you to open files for editing, close editors, save editor content and
rename files. Among the other things, it also allows you to import and export workspace
content and shutdown Eclipse.
2 Edit
Applications Development and Emerging Technologies Page 12 of 14
How to write Java Program Using Integrated Development Environment(IDE)?
Source
3 The Source menu is visible only when a java editor is open. It presents a number of useful
menu items related to editing java source code.
Navigate
4
The Navigate menu allows you to quickly locate resources and navigate to them.
Search
5 The Search menu presents items that allow you to search the workspace for files that
contain specific data.
Project
6
The menu items related to building a project can be found on the Project menu.
Run
7 The menu items on the Run menu allow you to start a program in the run mode or debug
mode. It also presents menu items that allow you to debug the code.
Window
8 The Window menu allows you to open and close views and perspectives. It also allows
you to bring up the Preferences dialog.
Help
9 The Help menu can be used to bring up the Help window, Eclipse Marketplace view or
Install new plug-ins. The about Eclipse menu item gives you version information.
Applications Development and Emerging Technologies Page 13 of 14
How to write Java Program Using Integrated Development Environment(IDE)?
EXERCISE 1
A student will create a C program. What possible editor will be used to create the program?
EXERCISE 2
Your school would like to create simple registration system to help students enrolled in the college.
Are you willing to use Integrated Development Environment (IDE) to develop the registration system?