Keep Eclipse sane
Eclipse is opinionated. Don’t argue with it, work the way it wants you to.
Eclipse keeps projects inside workspaces. When you start Eclipse it will ask you which workspace you want to use. You should always point this at either an existing Eclipse workspace or an empty folder, never a folder that has other files in it (e.g., your desktop). Eclipse will automatically add some special files to the workspace folder that store your preferences and other information.
The Golden Rule of Eclipse is never modify anything in the workspace folder from outside Eclipse. This is a sure way to get Eclipse confused, and that way lies madness. If you want to add files, delete files, rename files, etc., always do it through the Eclipse interface, not Windows Explorer.
Understand the interface
The Eclipse interface is based a single window containing a perspective, which is designed around a large-grained task like Java programming, repository exploring, debugging, etc. Perspectives are built out of views, like code editors, project explorers, consoles, and so on.
You can change perspectives using Window → Open Perspective and you can add views to a perspective with Window → Show View. Recently-used perspectives also show up as icons at the top right of the main Eclipse window. Views can be maximized, minimized, closed, opened, docked together, pulled apart, moved around, and so on. The flexibility is wonderful, but it’s easy to get confused.
If Eclipse looks weird, you’re either in the wrong perspective or you've done something odd to your views. So, make sure you're in the perspective you want, then choose Window → Reset Perspective...
On Windows and Linux, you’ll find Preferences under the Window menu. On Mac OS you'll find it under Eclipse. You should turn on:
- General → Workspace → Build automatically
- General → Workspace → Save automatically before build
- General → Editors → Text Editors → Show line numbers
There are lots of preferences; if Eclipse isn't working quite the way you want it to, you may be able to change its mind. But keep notes of what you do, so you can replicate any changes on a different installation!
Learn the tool
Eclipse is a full-blown professional programming environment with an incredible amount of power. No, you don’t have to master all its awesomeness to use it — but, almost every common task can be made easier if you learn your way around. Explore the menus! The Source and Refactor menus in particular are loaded with goodies. My four personal favourites are:
Source → Format or
F: auto format all code in the editor
Source → Toggle comment or
/: comment or uncomment the current line or selection
Refactor → Rename or
R: smart renaming for anything
Source → Organize includes or
O: automatically add and smart-sort include statements
Export a project
To export a project from Eclipse for lab submission:
Right-click the project name in the Project Explorer view and choose Export, then General → Archive File → Next.
You'll see your project in the left-hand panel with a checkmark next to it. Un-check the project name, then click the triangle beside the name to reveal the sub-folders. Add a check-mark to the
In the panel below, ensure the following are selected: Save in zip format, Compress contents of file, and Create only selected directories.
Click Browse, navigate to where you want to save the exported file, and give it a name, which should be something like
Phillips-Lapointe-Lab3.zip, assuming your name is Phillips, your lab partner's name is Lapointe, and this is lab 3.
Install Eclipse on your own computer
If you don't already have the Java 8 Development Kit (JDK) on your computer, get it from Oracle’s Java Download site and install.
Download and install the Eclipse IDE for Java Developers. In the lab we are using Eclipse Luna SR2 and the download you want will probably be the first choice on the page. Don’t get the Java EE version by mistake!
That should do it, but if it doesn't, see the Eclipse installation guide.