Working with Eclipse for Windows Developers (Part 2)

In Working with Eclipse for Windows Developers (Part 1), you discovered how to get Eclipse installed and setup for use on a Windows system. It’s a simple process, but it’s also much different than a standard installation, so it’s quite understandable that many people will become confused by the installation requirements. In today’s post, you see how to open the code for a book. Again, it’s a simple process once you know the secret handshake, but Eclipse doesn’t quite do things in the way Windows users expect in all cases.

When the previous part of this series ended, you should have created as Start menu entry and possibly a Desktop or Taskbar shortcut for Eclipse. Use any of these links to open a copy of Eclipse now. You’ll see a dialog box like the one shown here.

Eclipse0201

Eclipse uses the workspace folder to access the project you’re working on. All of the files for a particular book will be stored in a central folder. For example, when you work with the Java eLearning Kit for Dummies, the examples will appear in a folder named Java eLearning Kit for Dummies.

Click Browse and you’ll see a Select Workspace Directory dialog box where you can select the folder you want to use. This folder must appear on your hard drive, not on a DVD or other media that you can’t write data to. In addition, you must have the proper rights to write data to the directory because Eclipse will do just that as you work with it.

Eclipse0202

Select the folder you want to use and click OK. You’ll now see the folder location in the Workspace field of the Workspace Launcher dialog box. Click OK again. At this point, you’ll likely see a dialog box with a bunch of icons in it for doing things like working through the Eclipse tutorial. Notice that one of the options will take you to the Eclipse Workbench as shown here.

Eclipse0203

Click the Workbench icon. You’ll see a blank Workbench, like the one shown here, which doesn’t seem particularly useful.

Eclipse0204

Right click in the Package Explorer and choose New | Java Project. You’ll see a New Java Project dialog box. Type Chapter 01 (or whatever the chapter folder name is for the particular book) in the Project Name field as shown here.

Eclipse0205

Click Finish. You’ll see the source code in Chapter 01 added to your workspace so that you can now interact with the examples in the book. Here is what your Project Explorer could look like now (again, it may be different depending on the book).

Eclipse0206

To open one of the source files, just double click its entry in  Package Explorer. You’ll see the project opened in the editor window where you can examine its code.

You have several options for running an example. The fastest is to right click the example entry in Package Explorer and choose Run As | Java Application from the context menu. You may see a dialog box telling you about certain conditions and asking if you want to proceed. Click Proceed. If you have the file open in the editor, you can choose Run | Run to run the application. In either case, you’ll see the Console window become active next as shown here for the SayHello.java example from Chapter 01 of my book.

Eclipse0207

The Console window displays the application output. If the application requires input, you can click in the Console window and type any value you need to type. Press Enter to enter the input, just as you would at the command line. When the application stops running, you’ll be able to work with the editor again. Let me know if you have any questions about opening, examining, and running book source using Eclipse at John@JohnMuellerBooks.com.

 

Author: John

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 99 books and over 600 articles to date. The topics range from networking to artificial intelligence and from database management to heads-down programming. Some of his current books include a Web security book, discussions of how to manage big data using data science, a Windows command -line reference, and a book that shows how to build your own custom PC. His technical editing skills have helped over more than 67 authors refine the content of their manuscripts. John has provided technical editing services to both Data Based Advisor and Coast Compute magazines. He has also contributed articles to magazines such as Software Quality Connection, DevSource, InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software Test and Performance, and Visual Basic Developer. Be sure to read John’s blog at http://blog.johnmuellerbooks.com/. When John isn’t working at the computer, you can find him outside in the garden, cutting wood, or generally enjoying nature. John also likes making wine and knitting. When not occupied with anything else, he makes glycerin soap and candles, which comes in handy for gift baskets. You can reach John on the Internet at John@JohnMuellerBooks.com. John is also setting up a website at http://www.johnmuellerbooks.com/. Feel free to take a look and make suggestions on how he can improve it.