Mindtelligent, Inc. Eclipse Tutorial
Mindtelligent, Inc. Eclipse Tutorial
Mindtelligent, Inc. Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
Table Of Contents Eclipse - Important concepts. ...................................................... 3 Perspective.................................................................................. 4 Plugins......................................................................................... 5 Changing the workbench arrangement:.................................. 8 Eclipse installation...................................................................... 11 Adjusting the default settings .................................................... 13 Structure of folders in new Java projects.............................. 13 Switch compiler and editor to JDK 1.4 ................................. 15 Use JDK instead of JRE (or install new JRE/JDK).............. 16 Set classpath variables............................................................. 18 The first Java-Project................................................................. 20 Importing an existing project .................................................... 24
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
Perspective
To open a new perspective in the workbench do the following: 1. Choose 'Window -> Open Perspective' in the main menu:
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
Plugins
To install new applications, simply copy the plugins into the folder $ECLIPSE_HOME/plugins as shown here with the Tomcat plugin. You have to restart Eclipse to be able using the newly installed plugins. Depending on the plugin you now can choose a new perspective, find new entries in the menu and toolbar (as with the Tomcat plugin) or find new features in other structures. Hope that your plugin ships with decent documentation!
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
Workspace As default the root folder for the workspace is $ECLIPSE_HOME/workspace. If you take part in several projects or use a shared computer it makes sense to separate the workspace. You can choose an arbitrary directory for your workspace root folder with the -data option at Eclipse startup. For example eclipse -data c:\MyWorkspace.
Adding views to a perspective: 1. Open a perspective, e.g. the Java perspective. 2. Choose 'Show View -> Navigator' in the menu:
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
To add a view or editor as tabs do the following: 4. Left-click the title-bar of the view or editor that should be moved: (here: outline view) 5. Drag the curser (with pressed mouse button) on the title-bar of another view or editor until the cursor changes into the tab symbol:
Manipulating resources with external tools If you change resources in the workspace with external tools, there's no automatic notification. If the resource you changed externally is opened in a Eclipse editor you will be asked if you want to load the changes from the disk:
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
If you create new files or folders in your project folder externally you have to tell Eclipse: 1. Select the folder in which you created the new files / folders in a view (e.g. navigator). 2. Choose 'File -> Refresh'
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
Eclipse installation
You need: System with Windows, Linux, Solaris, QNX or Mac OS/X operating system. Preferably 256 MB RAM or more. A Java 2 runtime environment (JRE) or Java 2 Software Development Kit (J2SDK). Eclipse needs version 1.3 or higher . We recommend JDK 1.4.1 as it has the least problems with hot code replacement and is the fastest. This is the Java-version that Eclipse (a Java application) runs with, not the version you develop for! Eclipse 2.0.1-archive. Either the Platform Runtime Binary Archive together with the JDT Runtime Binary oder the Eclipse SDK. 1. Install JRE resp. J2SDK. 2. Extract the Eclipse-archive to an arbitrary location on your hard drive. You have to keep the path settings. In Windows you could unzip directly to C:\. You will get a C:\eclipse directory (from now on referred to as eclipse_home ). Under Unix you could use the /opt-directory. In Windows Eclipse finds an installed JRE/SDK automatically via the registry. Alternatively you can copy the jre-Folder (including its contents) into the eclipse_home directory. Another option is to specify the path to the JRE/SDK with the command-line option -vm. 3. Start Eclipse by executing eclipse.exe resp. eclipse.sh in the eclipse_home directory. You will see a splash screen and after some time the workbench will show up:
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
5. Press button 'Browse' in the line 'JRE home directory'. 6. Choose installation directory in the folder selection dialog. Under Windows this could be C:\j2sdk1.4.1. 7. Press 'OK' for folder selection. 8. Press 'OK' for dialog 'Edit JRE'. 9. Press 'OK' for dialog 'Preferences'.
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
4. Specify the variable name in the text field next to 'Name'. 5. a) If a variable should point to a file (zip- or jar-archive), press the button 'File'. b) If a variable should point to a folder, press the button 'Folder'. Variables pointing to a folder must be extended to a complete path from within the project where they are used. That means there have to be zip- or jar-archives in the folder that are going to be added to the build path. An according dialog pops up.
6. 7. 8. 9.
Choose the file or folder in that dialog. Confirm the dialog. Press 'OK' in the dialog 'New Variable Entry'. Press 'OK' in the dialog 'Preferences' Dialog.
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
3. Choose a non existing name for your project, e.g. "MyProject default for the project folder is workspace_home/MyProject 4. Press 'Next'. The 'New Java Settings' dialog pops up: This dialog really is editing the .classpath file. This file is stored in the project folder and can be changed any time.
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
The 'Source' tab lets you specify folders that contain Java sources (.java files). Default after installation of Eclipse is the project folder but we will separate the sources from the compiled code.. If you have done the adjustments of the default settings you don't have to do steps 5-9. 5. Select the radio button 'Use source folders contained in the project'. 6. Press the button 'Create New Folder'. The 'New Source Folder' dialog pops up:
MindTelligent, Inc.
Eclipse Tutorial 8. Press 'OK'. The 'Source Folder Added' dialog pops up.
http://www.MindTelligent.com
9. Press 'Yes'. The output folder for compiled classes will be specified as workspace_home/MyProject/bin . The dialog 'New Java Settings' looks like that now:
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
4. Press 'Next'. The 'Import File System' dialog shows 5. Specify the directory that contains the project to import with the first 'Browse' button. This directory is the root for the following selection dialog. 6. Select the folders and files that should be imported into the project.
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
7. Specify the folder in that you want to import the files with the second 'Browse' button. You can choose here between existing project folders an their subfolder. (If the build path is already set it's important to specify the correct source folder, see below) The option 'Create complete folder structure' also creates the folder hierarchy in the project folder.
8. Press 'Finish'. The selected folders and files have been added to your project. 9. According to the structure of the imported Java project the build path has to be set. The above example only imported source files of a JBuilder project. In JBuilder these reside in a folder 'src'. If the adjustments of the default settings
MindTelligent, Inc.
Eclipse Tutorial
http://www.MindTelligent.com
have been done, this folder already also is the source folder of the (Eclipse) Java project.
MindTelligent, Inc.