Eclipse (a Java IDE) - First Steps
(Free Web Tutorial)
by Michael Thomas
Eclipse Home Page
In this tutorial you will install Eclilpse 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 UML Home page, you can download
the whole UML site (all content, tutorials & examples) !!!
This tutorial covers: Eclipse Helios (IDE for Java EE Developers)
(1.3.0) (as of 08/11/2010) - Version: Helois Release, Build ID:
20100617-1415 - Eclipse Platform: 3.6.0
Install file:
eclipse-jee-helios-win32-x86_64.zip
Prerequisites
- Have JDK 5 or high installed.
I Tested with: JDK 6 Update 21 (Version: 1.6.0_21) - the latest as of
08/11/2010 that is not beta.
- This tutorial has been tested in the following environment:
Date: 08/11/2010;
OS: Win 7;
JDK: 1.6.0_21
(Older Tutorial -
Date: 05/19/2008, OS: Win XPro, JDK: jdk1.6.0_03)
Objectives
- Install Eclilpse 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
Eclipse General Info
- Eclipse version - Help, About Eclipse
- JVM version used to run programs:
- Launch Eclipse. Help, About Eclipse,
- Click "Installation Details"
- Click the tab "Configuration"
- JRE version used to run your programs.
- java.version
- java.vm.version
- JDK version used to compile java programs using "javac.exe"
- Look for the property: java.library.path
java.library.path=C:\Windows\system32;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;
etc.....
C:\java\jdk1.6.0_21\bin
FYI - Possible Errors:
Eclipse Install
- Prerequisites - JRE (Java Runtime Environment)
- Download Eclipse
- www.eclipse.org
- (for older versions of Eclipse use:
http://archive.eclipse.org )
- Click "Downloads" tab at the top to go to the "Main Eclipse
Download" page.
- Next you'll see the "Eclipse Download" page. If you want
Linux or Mac downloads use the pulldown (default is Windows).
- Find the row to download software: Eclipse IDE for Java EE
Developers, 206 MB
To the right click on "Windows 32 Bit" or "Windows 64 Bit" depending
on your OS. (Note: Win 7 is normally 64 bit - Start,
Computers, System Properties and look for "System Type")
Click the download icon arrow to download the file:
eclipse-jee-helios-win32-x86_64.zip
- Notes:
- Package Details: Tools for Java
developers creating Java EE and Web applications, including a Java
IDE, tools for Java EE, JPA, JSF, Mylyn and others.
- On the Download Page, Click "Compare Packages" to get a chart of
what has what.
http://www.eclipse.org/downloads/compare.php
Eclipse Java EE has:
- RCP/Platform
- CVS - Concurrent Version System -
http://www.cvshome.org
- EMF - Eclipse Modeling Framework
- GEF - Graphical Editing Framework
- JDT - Java Development Tools
- Mylyn - Task focused development.
- Web Tools
- Java EE Tools
- RSE
- Eclipse Link
- PDE - Plugin Development Environment.
- DTP - Data tools
- 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.
- Install Eclipse
- 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.
- Warnings: JRE build 1.6.0_21-b06
The Eclipse web site has a warning that reads:
Attention Windows users running Java 1.6.0 update 21 with Eclipse.
Please follow the instructions here to resolve crashing and freezing
issues.
http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Oracle.2FSun_VM_1.6.0_21_on_Windows
If your running b07 or higher it should be fixed. The problem
appeared to show up in version b06.
See the DOS command below that will give you the version of JRE you are
using that Eclipse will use.
C:\>java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
- Launch Eclipse (Helios)
- Create a directory for your workspace: c:\eclipseworkspace
- Launch Eclipse by running the executable: C:\eclipse\eclipse.exe
(Note: I use Win Explorer to launch the executable.)
- Workspace = c:\eclipseworkspace
- Click OK.
- 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.
Create a Test Java Project & Java Class
- Create a test Java Project
- File, New, Project
- Click "Java Project", then Next
- 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.
Project Layout: Select - "Create separate folders for sources and class
files.
- Click "Finish"
- Click "Yes" - Open Associated Perspective.
- 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
- 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.