| CSC 207 | Grinnell College | Fall, 2018 |
| Algorithms and Object-Oriented Design | ||
This reading describes the basic steps required to use Elipse to run a simple Java program.
Eclipse organizes software into three basic units:
The following discussion is based on a class Course.java within a packabe course. Using this example provides a focus for the beginning use of the Eclipse IDE.
To get started with Eclipse, follow these steps:
Type
eclipse &in a terminal window.
The first time you run eclipse, the software will want to identify a base directory for all work with Java. The default is directory eclipse-workspace within your home directory. Accepting this default seems appropriate for most users.
Once you have started Eclipse, note that a "Welcome" panel appears on the right hand side of the environment. Working through this tutorial will show you many of the basic elements of Eclipse, largely paralleling what follows.
Create a project by going to File ⇒ New ⇒ Project. A form will ask you to name the project; "Examples" is one generic name, but you are free to choose any name you wish. The form also allows various options for setting up a project. It is suggested you use the default settings by clicking finish.
Create a package by going to File ⇒ New ⇒ Package. As already noted, this reading uses package course, although any valid Java identifier would work. (In the Eclipse form, use the default for the Source folder.) When this step is completed, package course should appear under the source (src) heading within Examples
Create a class by going to File ⇒ New ⇒ Class. Again use the defaults. When this step is completed, you will see a brief shell for a new Course1 class.
Open the existing Class Course.java in your browser, and use copy-and-paste to insert the code (without the package or Class header) into Eclipse. After the paste operation, change Course to Course1 throughout. (The Edit menu has a typical Find/Replace option.)
Import a class by going to File ⇒ Import. The full path name for the sample Course.java is
/home/walker/public_html/courses/207.fa14/java/course/Course.java
That is,
First you will need to identify the directory of the program (click the check box for the directory to proceed). Then you will need to identify the appropriate file (you might want to use the browse option (twice) to find both the relevant directory and the needed file.)
Compile and run by
|
created 17 January 2012 revised 20 January 2012 revised 1 September 2014 revised 30 August 2018 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |