Getting Started Using Eclipse
|1.0||Background of Eclipse|
|4.0||Editors and Views|
|6.0||Creating a Java Project|
|7.0||Creating a Java Package|
|8.0||Creating a Java Interface|
|9.0||Creating a Java Class|
|11.0||Running the Program|
Eclipse is an Integrated Development Environment (IDE) that is open source and maintained by many software development leaders like IBM and Borland. The idea behind the Eclipse platform is to provide a common environment that companies can modify and customize by creating plug-ins. Plug-ins are created to do some specific tasks that a work group might need while developing a software product. The plug-ins and modification of the Eclipse platform can later be distributed royalty free.
This tutorial introduces you to the user interface of Eclipse and some common activities that can be done in the Eclipse environment. Large images are displayed as thumbnails, but are linked to a page of full size images. For this tutorial we are using Eclipse 3.5.x.
Download Eclipse from here. For web development, you will want Eclipse IDE for Java EE Developers You need the Java Runtime Environment (JRE) to use Eclipse; we are using Java Version 5.0, which can be downloaded here. Be sure to select the JRE and not the SDK, because you do not need the Java source files to use Eclipse.
After you download Eclipse, you will want to unzip the folder to right under your C drive (or main hard drive). However, you can install Eclipse into whichever directory you want. Eclipse is run by launching the eclipse.exe executable which is at the top level of the Eclipse directory.
The base functionality of Eclipse can be extended through the use of plug-ins. These plug-ins can add functionality to Eclipse like modeling, UML, XML, metrics, reliability reports, and other information. The Eclipse web site has a list of links to many popular plug-in repositories. Check out the Installing Plugins tutorial for more information.
Eclipse has two main components for displaying information about a project. These are editors and views.
4.3 Moving Editors and Views
Perspectives show all functionality associated with a large task, for example the Java Perspective is associated with creating a Java application. Each perspective has a default layout with views and editors appropriate for that task. If the views and editors are moved within a perspective, Eclipse will remember the new layout.
5.1 Opening a Perspective
5.2 Views in a Perspective
5.3 Switching Between Perspectives
5.4 Closing Perspectives
6.1 There are three ways to create a Java project:
6.2 Select Java project and click Next.
6.3 Give the project a name. If you would like to create src and bin folders for your java and class files respectively select the Create separate source and output folders radio button under the Project layout area of the New Java Project dialog. The default source folder is src/ and the default output folder is bin/. You can change these defaults by clicking on the Configure default... link. Click the Next button.
6.4 The next screen has four tabs: Source, Projects, Libraries, Order and Export. The source tab sets the source and output folders for Java files and class files. The project tab allows you to connect your new Java project to any other Java projects that are needed on the new Java project's build path. The libraries tab allows you to attach jar files of and Java libraries that you may need. The order and export tab determines the build order and how a project can be exported. Make any changes needed here, and then click the Finish button. If you are not in the Java perspective, Eclipse will ask if you would like to switch to the Java perspective. The project will show up in the Package Explorer view.
7.0 There are four ways to create a Java Package. First, select the project you wish to create a package in.
7.2 Check to make sure that you are creating the package in the proper project and source folder. Give the package a name. Click Finish.
8.1 There are four ways to create a Java Interface. First, select the package you wish to create the interface in.
8.2 Check to make sure that you are creating the interface in the proper package. Give the interface a name. Use the Add button to add interfaces that the new interface needs to extend. You may also select if you want generated comments added to the interface. All generated comments are configurable under Window > Preferences > Java > Code Style > Code Templates. Click Finish. The new Interface will be open in the editor.
9.1 There are four ways to create a Java Class. First, select the package you wish to create the class in.
9.2 Check to make sure that you are creating the Class in the proper package. Give the class a name.
9.3 Click Finish. The new class will be open in the editor.
|Eclipse maintains a history of changes made to all files open in the workbench. If you need to revert a file to a previous version, or you just wish to find a line of code that you deleted, you can look up the local history of the file. This history is only persistent for the life of the Eclipse session. To look up the local history of a specific file, right click on the file and select Compare With > Local History.. or Replace With > Local History... depending on the operation you wish to do.|
There are several ways to run a program.
11.1 If the program has never been run before, you need to create run configuration for the program.
11.2 Select Java Application, then click the New button at the bottom left of the screen. This creates a new run configuration. Give the setting a name. If the project is not specified, you can Browse for it. To find the main class in the project, select the Search button.
11.3 If there are any command line arguments, enter them in the Program arguments text box under the Arguments tab.
11.4 You can add jar files to the classpath under the Classpath tab.
11.5 Click Run to run the program.
11.6 If you have already created a run configuration, you can select the configuration by name by selecting the arrow on the icon in the tool bar. Just pressing the green button will run the last configuration launched by Eclipse.
Following computer science tradition, you will now write a simple HelloWorld application using Eclipse. We will call our application Greeter, and it will be able to say hello in several different languages. The diagram below shows that EnglishGreeter, FrenchGreeter, and SpanishGreeter extend the abstract class Greeter.
For this exercise create a Greeter program that can say hello in three different languages. You can just print the hello statements to System.out. Show the application to your TA for credit.