Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Before we continue on with learning about the Java programming language, I'd like to give you a tutorial on how to navigate around the Eclipse IDE. Eclipse has its own vocabulary, how to refer to various areas of the Eclipse interface and how to configure it. I am going to start with showing you how to import existing projects. If you have access to the Exercise Files for this course, you'll see that they are stored in Chapters. For example, the projects for the current chapter Getting Started are in this folder, 03_GettingStarted.
Each of these folders constitutes an Eclipse project. I'll double click into one of them named ExploreEclipse. You'll see that it contains a source folder; that's where your Java files go, and a bin folder; that's where the compiled classes are placed. There are also two files named .classpath and .project. If you are working on Windows, you should see them in Windows Explorer. If you are working on a Mac, you won't see the files with the dot prefix displayed in Finder, but they are there.
These are XML files that are used to configure the current project. You can actually work with these files outside of Eclipse very easily, but I've configured them to be importable into Eclipse so you can get started with each lesson very quickly. Here is how you would import that project into Eclipse. From the Eclipse Menu, go to File>Import. In the Import dialog, go to General, and then Existing Projects into Workspace, and click Next.
You can import projects from two formats; an exploded project, where you can see the actual files on disk, that's the kind of projects that I am using; and archived files that are in ZIP format. I won't be using those during this course. So I am going to choose a root directory of an existing project. I'll click Browse. I'll navigate to my Exercise Files, 03_ GettingStarted folder, and I'll chose ExploreEclipse, and click OK. Eclipse detects that there is a project in that folder and it displays the project and checks it by default.
All I am going to need to do is click Finish. But before I do, I'll show you that there is an option labeled Copy projects into workspace. If you leave that option unselected, you'll be importing the existing project into the workspace so that it's displayed in the Package Explorer on the left side of the Eclipse UI, but you'll still be working with the original code. If you check this option, you're making a copy of the project, and the project will be copied into the root folder of the workspace itself. I'll be leaving this option unchecked throughout this course so that I am working with the actual files that I am delivering in the Exercise Files bundle.
I'll click Finish, and that imports the project. I can now open the project, open its source folder, its default package, and there is the code, HelloWorld.java. Now, notice I now have two projects opened and they both have classes named HelloWorld. How do I know which one I am looking at? Here is a little trick, if you move the cursor over the tab, you'll see the entire path, starting with the project name, so this file is for the ExploreEclipse project.
I'll open the class from the HelloWorld project and move the cursor over that tab and show that the pop- up help shows HelloWorld. So when you have multiple classes of the same name, sometimes with more than one project, sometimes within different directories or packages within the same project, you can easily find out which one you are working with. Now, I typically try to keep only one project open at a time. So I am going to go back to my original HelloWorld project, I'll right click on it and choose Close Project.
And now I'm only left with the HelloWorld.java file from ExploreEclipse. Here are some important terminologies as you work with Eclipse. Each of the rectangular areas is called a View. You might think of those as panels if you've worked say with Adobe or Microsoft software, but Eclipse calls them Views. By default, there is a Package Explorer View, down at the bottom there is Problems View for displaying code problems, a Javadoc View, a Declaration, a Console, and so on.
Over on the right there is something called the Task List View. This is a part of a plug-in called Mylyn, that's delivered automatically with this distribution of Eclipse. We won't be using this plug-in during this course, so I am just going to get rid of it by clicking the Close icon. The other view that appears on the right side by default is called the Outline View, this one is very useful because it lets you navigate around in your code without having to scroll up and down. As your code gets more complex and you have a lot more of it, it's a lot easier to find the code by using the Outline.
Even though this is a very simple class, I can demonstrate this by clicking on the main method, and you'll see that, that method name is highlighted and the cursor moves to that location in the code. So we'll keep the Outline View open. As you work with your code and you have wider lines, you might want to expand the Editor so that it's Full Screen. To do this just double click on the tab at the top of the Editor and that will maximize it. Double click again and it will restore to its original size. I'll also show you that you can expand any of the views, not just the Editor.
I'll maximize the Package Explorer and restore it; I'll maximize the Problems View and restore it, and so on. Every view behaves exactly the same. Another concept that's important to know about in Eclipse is Perspectives. A Perspective in Eclipse is a particular arrangement of views. So the Java Perspective, which is the default Perspective when you first open this Eclipse distribution, has the Package Explorer on the left, the Editor in the center, the Problems, Javadoc, and Declaration View at the bottom and so on.
You can create your own custom Perspectives. So for example, I have the Console View open now, because I've run an application; it's not typically open when you first start the Java Perspective. I have also closed the Task List View. Now I am going to save this as my own custom Perspective. I'll go to the Menu and choose Window> Save Perspective As, and I'll call this CustomForJava, and click OK. I can now switch between different Perspectives.
I can go to the Menu and choose Window> Open Perspective, and I'll see a couple of default Perspectives here; one called Debug and another one called Java Browsing. I'll click Other and I'll see a whole bunch of different Perspectives listed. Java was the default, I'll choose that, and you'll see that the original Perspective or layout returns, including the Task List. But up in the upper right hand corner I now see my CustomForJava Perspective displayed. You can actually move the cursor to the left of the Perspectives and drag this out, so you can see as many Perspectives as buttons as you have available.
And you can easily now switch between them by clicking the appropriate button. I'll typically be using this CustomForJava Perspective throughout the course, but you can create your own Perspective and layout the application however you like. I'll show you one more trick. You can detach any of the views and have them float above the rest of the Eclipse UI. This is particularly useful if you have more than one monitor and you want to move one of the views off to the second monitor. To do this, you right click on the tab for the View and choose Detached.
Now, you can move the view around, you can expand it, and if you have that second monitor, you can move it off to the second monitor. To reattach it, right click on the tab and deselect Detached. The view might drop into an area you don't want. For example, the Outline View just dropped into my bottom dock. But you can click on the tab and drag it wherever you want. So now I've placed it back in its original location. And if at any point you've really messed up your views in a way that doesn't work for you, for example, I am just sort of randomly moving things around now to really mess up my system, you can always reset a Perspective.
Go to the Menu and choose Window>Reset Perspective, and click Yes to confirm. And your original Perspective will return. So that's a look at how to navigate around the Eclipse user interface. I've shown how to use Views and Perspectives, how to create your own custom Perspective, and how to detach views and move them around if you prefer, and finally how to reset a Perspective if you don't like the way things have ended up.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99874 Viewers
56 Video lessons · 112990 Viewers
71 Video lessons · 81827 Viewers
131 Video lessons · 39263 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.