Eclipse (a Java IDE) - First
Steps
(Free Web Tutorial)
by Michael Thomas
Eclipse Home Page
In this tutorial you will install Eclipse SDK,
create your first Java Project and then create the Java Cert
project for the "Free Java Core & Certification Training Web
Tutorial".
Note: On the Eclipse Home page, you can download the whole Eclipse site
(all content, tutorials & examples) !!!
This tutorial covers:
- Eclipse Mars.1 (4.5.1) (June
2015 release) as of 12/24/2015
Prerequisites
- Have a JDK installed. (Website Suggests: At or higher than:
Java SE 7)
- This tutorial has been tested in the following environment:
Date: 12/24/2015
OS: Win 7
JDK: Java SE 8u66
Objectives
- Install Eclipse SDK,
- Create your first Java Project
- Create a Java Project from an existing source.
(Note: You will download all of the files for the Java Cert
project for the "Free Java Core & Certification Training Web
Tutorial" and setup a project.)
Terms
- IDE - Interactive Development Environment
- JDK - Java Development Kit
- SDK - Software Development Kit
Eclipse Download
- Prerequisites - JRE (Java Runtime Environment)
- Download Eclipse
- www.eclipse.org -
(for older versions of Eclipse use: http://archive.eclipse.org
)
- Click "Downloads" button at the top to go to the "Main
Eclipse Download" page.
- In the burnt orange bar at the top select the
OS. This tutorial is for "Windows".
- Eclipses can be installed on the following OS:
Windows(32/64 bit), Linux (32/64), Mac OS X (64)
- Eclipse now has an "Installer" option, however, I will
cover the ZIP install.
- Locate the section: Eclipse IDE for Java
Developers
Download (~170meg): Click 32 bit or 64 bit depending
on your OS
64 bit File name: eclipse-java-mars-1-win32-x86_64.zip
- FYI Information:
- If updating Eclipse to a newer version - if you are
upgrading your Eclipse version read these notes.
- I like to launch my current version of Eclipse, click
"Help", then "About Eclipse SDK" and write down the version.
- Next, I'll rename my current directory from "c:\eclipse"
to "c:\eclipse_x.x.x" (using the version # for the
Xs). This way you can still launch the old version if
you want to.
- Note: Normally all of your projects will still show
up because you will specify your eclipse workspace which has
the meta data.
Eclipse Install
- Install Eclipse
- The zip file has the directory "eclipse" that has all of
the files in it.
Extract the zip file to: C:\
Note: The files will be extracted to:
C:\eclipse\... Make sure that zip programs
"Use folder names" is enabled.
- Create an Eclipse Workspace
- Create a directory for your workspace: c:\eclipseworkspace\MyEclipseTestWS
- Launch Eclipse
- Optional: Create a Shortcut
- Win 7 - Create an entry in "Start"
- Using Windows Explorer, navigate to: c:\eclipse.
- Right click on the file "eclipse.exe" and choose
"Create Shortcut".
- Now left click on the file "eclipse.exe - Shortcut"
and drag it on top of the Windows "Start" icon in the
very bottom left corner of your computer.
Windows will "pin" it to the "Start" button.
- Note: You can do the same thing to your Desktop.
- Win XP - Create an entry in "Start", "All Programs"
- Right click on "Start", choose "Explorer all users",
- Click on "Programs"
- Click "File", "New", "Shortcut"
- For location of item, browse to: C:\eclipse\eclipse.exe
- Click next.
- Name for the shortcut: Eclipse
- Click "Finish"
- Click "Start", "All Programs"
- Click "Eclipse" to launch the program.
- Test your shortcut.
- You have installed Eclipse!
- Now visit the "Must Know ASAP" section of the "EclipseSurvival Guide"
page.
Create a Test Java Project & Java Class
- Create a test Java Project
- File, New, "Java Project"
- Project name: MyJavaTest
- Note the other Defaults:
"Use default location" should be checked so the project will
be located: c:\eclipseworkspace\MyJavaTest
JRE - notice the location of the JRE. (JavaSE-1.8)
Project Layout: Select - "Create separate folders for
sources and class files.
- Click "Next"
- Click "Finish"
- Note: Use Windows Explorer and look at the directories and
files that were created under the new directory!
C:\eclipseworkspace\MyJavaTest\.classpath
C:\eclipseworkspace\MyJavaTest\.project
<DIR> C:\eclipseworkspace\MyJavaTest\.settings
<DIR> C:\eclipseworkspace\MyJavaTest\bin
<DIR> C:\eclipseworkspace\MyJavaTest\src
C:\eclipseworkspace\MyJavaTest\.settings\org.eclipse.jdt.core.prefs
- Create a new Java Class
- File, New, Class
- Source Folder: should be defaulted to:
"MyJavaTest/src".
- Name: MyApplication
- Which method studs would you like to create?
Check - public static void main(string[] args)
- Click "Finish"
- Make the java class have the following code:
public class MyApplication {
public static void main( String [] args ) {
System.out.println("Hello World from an
Application.");
}
}
- Save the application with
"Ctrl-S".
- Click "Run" (the green play
button)
(Or click the black down arrow, "Run As", "Java
Application")
- In the "Console" window at the
bottom you should see the following:
Hello World from an Application.
- Click the "Clear Console" icon (Paper with an X in it) in
the panel of icons to the top right of the console output.
- Congratulations - you have created and tested you first
Java Application.
- Notes
- C:\eclipseworkspace\MyJavaTest - has the files you
just created.
You just added these two:
C:\eclipseworkspace\MyJavaTest\bin\MyApplication.class
C:\eclipseworkspace\MyJavaTest\src\MyApplication.java
Create a Java Project from an Existing Source ("javacert"
project from this website)
- You can setup Eclipse to access all of my Java Certification
examples that I have at my web site on your local PC.
- Click on the link below and look for the section titled
"Download Files".
Free Training: Sun Certified
Java Programmer Exam
Extract the zip file into the directory: C:\eclipseworkspace
(When you extract the file it will create a directory called
"javacert".)
Example:
C:\eclipseworkspace\javacert (Note: You can
place it in a subdirectory of some other directory if you
want. I have mine elsewhere!)
- Launch Eclipse
- Create a Java Project from an existing source.
- File, New, Java Project, Next
- Project Name: javacert
- UnCheck - Use default
location.
- Location: Click browse and navigate to the directory.
(ie:
C:\eclipseworkspace\javacert )
- Click "Next"
- Verify "Default output folder" has this value:
javacert/classes
- Click "Finish"
- Test your new Java Project
- Expand "src".
- Expand "(default package)"
- Double click on "MyHello_Application.java"
- In the System.out.println() add your name. ex:
System.out.println("Hello World from an Application by
Michael Thomas.");
- Ctrl-S to save. Then click Run (Green play
button). See if the console has your change!
- Now you can edit and run the source code at my web site on
your local PC using Eclipse - HAVE FUN.