Академический Документы
Профессиональный Документы
Культура Документы
This section you create a project. Eventually, will contain a Java package, and the package will
contain a Java class.
1. On the Eclipse menu bar,
choose File. New Project.
You see the New Project dialog, as shown in
the Figure.
Formally, a project is a collection of files and
folders. Intuitively, a project is a basic work unit.
For instance, a self-contained collection of Java
program files to manage your CD collection (along with the files containing the data) may constitute
a single Eclipse project.
2. In the New Project dialog, select Java Project, and then click Next.
You see the New Java Project Wizard, as shown in the Figure.
3. In the Project Name field, type a name for your new
project.
I typed FirstProject. In the steps that follow, I assume
that you also type FirstProject. But if you insist, you can use
dashes, blank spaces, and other troublesome characters.
You have to type a name for your new project. Aside from
typing a name, you can accept the defaults (the Location and
Project Layout stuff) in the New Java Project Wizard.
4. Click Finish.
When you click Finish, the Eclipse workbench reappears.
The leftmost area contains the Package Explorer view. The
views list contains your new FirstProject. (See Figure.)
Creating a package
In the previous section, you create a project to hold your code. The next thing to do is add a package
to your project.
1. In the Package Explorer, right-click the
FirstProject branch. Then, in the resulting
context menu, choose New Package.
The New Java Package Wizard appears, as shown
in Figure.
2. In the New Java Package Wizard, type the name of your new package in the Name text field.
In above Figure, I typed the name com.allmycode.first.
For the package name, youre supposed to reverse your domain
name and then add a descriptive word. In this example I use
com.allmycode.first because Ive registered allmycode.com, and
this is my first example. If you follow this naming convention, other
Java programmers will like you. But if you dont follow this
convention, nothing breaks. For your own use, a package name like
almost.anything.atall (or even a one-part mypack name with no
dots) is just fine.
3. Click Finish to close the New Java Package Wizard.
Your new package (along with some other stuff) appears in the Package
Explorers tree.