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.

 

Working with Eclipse for Windows Developers (Part 1)

A number of my Windows readers have written to ask me about the Eclipse Integrated Development Environment (IDE). Part of the problem stems from the many versions of Eclipse. You can find a version of Eclipse for nearly any language out there. At least, it seems like there is a special version. What you really get is a plug-in for Eclipse Standard edition. Yes, if you’re working with C++, then getting the Eclipse IDE for C/C++ Developers makes sense. However, since I work with a lot of different languages, I simply download the standard edition and then tweak it as needed with the required plug-ins. The reality is that Eclipse is incredibly flexible.

 


When working with my books, all you need is the standard edition unless I specifically state otherwise in the book. Using one of the special editions can make Eclipse a little more difficult to use and that’s something you really don’t need when you’re just starting out with a new language. In addition, unless my book specifically says otherwise, you don’t need to download any of the plug-ins. All of the plug-ins are there to extend the functionality of Eclipse, which is nice when you need it, but potentially confusing when you don’t.

After you have selected the flavor of Eclipse that you want by clicking its link, you’ll find that Eclipse typically comes in 32-bit and 64-bit versions for Windows, Mac OS/X, and Linux developers. If you’re using a 64-bit version of Windows, you’ll want to download a 64-bit version of Eclipse to ensure you can make maximum use of the operating system features.

Selecting a platform displays another page where you select the site you want to use for downloading the product. Generally speaking, choosing one of the mirror sites will provide greater download speed than the main site, but your experience will likely vary from mine. What you get is a .ZIP file containing Eclipse. Of course, most Windows users are used to getting an executable of some sort with a complete installation program. All you really need to do is extract the Eclipse files anywhere on your hard drive to use it. I normally place Eclipse in its own folder off the main directory so that I don’t run into read/write permission problems inherent in putting it in the \Program Files folder.

At this point, you can start using Eclipse. That might seem odd, but there really isn’t anything more you need to do. Of course, opening Eclipse by finding its location in Windows Explorer every time you want to use it is a pain. Use these steps to make things easier.

 

  1. Right click the Eclipse.exe file in the host directory and choose Copy from the context menu.
  2. Right click Start | All Programs and choose Open from the context menu. You’ll see a copy of Windows Explorer open that has the appropriate folder selected.
  3. Select the Programs folder in the left pane to open it.
  4. Create a folder for Eclipse and open it.
  5. Right click anywhere in the Eclipse folder and choose Paste as Shortcut from the context menu. You now have an easy way to access Eclipse from the Start menu.
  6. (Optional) Rename the shortcut to something that’s a bit easier to read, like Eclipse.


At this point, you can right click the Eclipse entry and choose Pin to Taskbar from the context menu to make it even easier to access. However, that’s really all there is to installing Eclipse. Removal is even easier—just delete the shortcuts you’ve created, along with the Eclipse folder. Let me know if you encounter any problems getting Eclipse on your system at John@JohnMuellerBooks.com.