Book Image

Getting Started with Eclipse Juno

By : Rodrigo Fraxino Araujo, Vinicius H. S. Durelli, Rafael M. Teixeira
Book Image

Getting Started with Eclipse Juno

By: Rodrigo Fraxino Araujo, Vinicius H. S. Durelli, Rafael M. Teixeira

Overview of this book

<p>Integrated Development Environments (IDEs) such as Eclipse are examples of tools that help developers by automating an assortment of software development-related tasks. By reading this book you will learn how to get Eclipse to automate common development tasks, which will give you a boost of productivity.<br /><br />Getting Started with Eclipse Juno is targeted at any Java programmer interested in taking advantage of the benefits provided by a full-fledged IDE. This book will get the reader up to speed with Eclipse’s powerful features to write, refactor, test, debug, and deploy Java applications.<br /><br />This book covers all you need to know to get up to speed in Eclipse Juno IDE. It is mainly tailored for Java beginners that want to make the jump from their text editors to a powerful IDE. However, seasoned Java developers not familiar with Eclipse will also find the hands-on tutorials in this book useful.</p> <p><br />The book starts off by showing how to perform the most basic activities related to implementing Java applications (creating and organizing Java projects, refactoring, and setting launch configurations), working up to more sophisticated topics as testing, web development, and GUI programming.</p> <p><br />This book covers managing a project using a version control system, testing and debugging an application, the concepts of advanced GUI programming, developing plugins and rich client applications, along with web development.</p>
Table of Contents (17 chapters)
Getting Started with Eclipse Juno
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
4
Version Control Systems
Index

Preface

The first version of Eclipse was released in the November of 2001. Since then, it has come a long way in terms of enhancements and number of users. Due to the many improvements it has undergone, over time Eclipse has become popular and received a great deal of praise. Nowadays, Eclipse is arguably the most widely used integrated development environment (IDE) for developing Java applications. It is free and open source, and is shipped with plugins for performing lots of software-development-related activities. In addition, more plugins can be easily downloaded and installed according to your personal needs and preferences. Another plus is that, since Eclipse is written mostly in Java, it is cross-platform.

If you have been using Java without the help of an IDE, you must have realized by now that Java can be rough and unnerving at times. Most of the time, the compiler (javac) does not display helpful error messages. Even something as simple as an omitted semicolon may cause it to display a lengthy list of error messages. Inside an IDE, this sort of problem can be spotted before you try to run the program. An IDE can even suggest solutions before you start scratching your head. Undoubtedly, using a full-fledged IDE provides a range of benefits. For instance, an IDE provides autocompletion of your code, it helps you to format your code properly, and some of them come with nifty plugins for testing, debugging, and keeping track of the changes that you make to your code.

However, despite all the benefits involved in using an IDE, let's be upfront; learning how to use one of these high-end development tools is no bed of roses. IDEs have a steep learning curve, which means that mastering such a tool usually takes time and effort. To make matters worse, sometimes, many developers try to learn a new programming language and an IDE in tandem.

This book will help you to overcome Eclipse's steep learning curve. After reading this book, you will be grounded in performing many development activities using Eclipse.

What this book covers

In this book, we cover Eclipse Juno that is, at of the time of this writing, the latest stable version of the IDE (it was released in June 2012). The book starts off by showing how to perform the most basic activities related to implementing Java applications (such as creating and organizing Java projects, refactoring, and setting launch configurations), working up to more sophisticated topics as testing, web development, GUI programming, and extending Eclipse's editors to suit your needs.

This book takes a hands-on approach, diving straight into using Eclipse without getting you bogged down in technical details. Here are some of the topics covered in this book:

  • Effectively using Eclipse to write Java code

  • Integrating JUnit 4 into Eclipse, develop, and run JUnit-based test methods

  • Managing your project using the version control system Git/EGit

  • Developing GUI applications using SWT

  • Advanced GUI development with examples

  • Using Eclipse WTP plugin to develop and deploy web-based Java applications

  • Extending Eclipse by developing new editors, views, and contributing to existing elements of the IDE

Chapter 1, Introduction, covers how to get started with Eclipse. It goes from how to get Eclipse up and running to a brief overview of the new and noteworthy features of Eclipse Juno.

Chapter 2, Java Development, covers basic Java development using Eclipse. To beginners, Eclipse can be quite intimidating. The main window contains lots of smaller windows and some of the smaller windows have a bunch of buttons and drop-down menus. This chapter is all about getting to know the main features of Eclipse for developing Java programs. We will go through all the steps to get you going from creating Java projects, detailing the Eclipse views used for Java development, Java code generation, to building and running Java projects, which involves setting up launch configurations. Also, we cover some refactorings, so that you will be able to improve your Java code – as you tackle more complicated projects will you see that refactoring is a very important aspect of Java development.

Chapter 3, Unit Testing with JUnit and Debugging, introduces JUnit, the most widely used framework for implementing unit tests in Java. You will learn how to set JUnit up so that it can be used in conjunction with Eclipse. In addition, this chapter describes the creation of test methods using JUnit's annotations. As you will see, annotations can also be used to inform JUnit when to skip a particular test method and whether or not a given method is expected to throw an exception. The chapter wraps up with an introduction on how to use Eclipse's debugger to pinpoint tough to find problems in your code.

Chapter 4, Version Control Systems, explains using Eclipse in conjunction with version control systems. When working on a complex software project (or one that involves more than one person), you need to use a tool that manages and tracks different version of the software project in question. This book covers CVS, SVN, and Git, and how to use it inside Eclipse through native and external plugins. After reading this chapter, you will be able to use them inside Eclipse to support collaborative development.

Chapter 5, SWT, covers graphical user interface (GUI) development with the Standard Widget Toolkit (SWT). This chapter introduces the most basic widgets as, for example, buttons, labels, and combos. In a way, this chapter lays the foundation for Chapter 6, More SWT.

Chapter 6, More SWT, builds on top of the previous chapter, showing how to make more appealing GUIs by introducing advanced widgets as, for example, toolbars and tables. This chapter also features a full-blown example.

Chapter 7, Web Development Using Eclipse WTP, is concerned with using Eclipse to develop basic web applications. Throughout this chapter we show how Eclipse, along with a set of plugins called Web Tools Platform (WTP), can be used to support the development of web applications that are based on two basic web technologies, namely, servlets and JavaServer Pages (JSP).

Chapter 8, Eclipse Development, covers a more advanced topic: extending Eclipse. You will learn how Eclipse's architecture is organized. Further, by reading this chapter, you will see how extension points can be harnessed in order to create your own plugin, editor, or even extend a particular view.

Chapter 9, Eclipse Rich Client Platform, shows how you can leverage what you have learned in the previous chapter to develop your own rich client application using the Eclipse Rich Client Platform. By creating a sample application, you will learn how to add views, menus, and panels, as well as make them interact with each other. We will also cover how to brand and package your application, allowing you to build a fully functional, cross-platform application using the Eclipse platform.

Appendix, Keyboard Shortcuts, contains all keyboard shortcuts presented throughout the book, plus other useful ones that can greatly improve your productivity with Eclipse.

What you need for this book

The two pieces of software needed for this book are a Java Virtual Machine (JVM) and Eclipse. Both are free and available for download. Some additional plugins and software are also required, but we will detail how to get and install them along the book. The next section details how to install Eclipse and provides some pointers on where to find information concerning how to install a version of the JVM.

Who this book is for

Although Eclipse can be used as IDE for a number of different languages, it is more popular within the Java community. We wrote this book with a Java programmer interested in getting the most out of Eclipse in mind. Therefore, the main focus is going to be Java development using Eclipse, and the primary audience for this book is the Java programmer.

The book was written in a way that it is accessible both to beginners and intermediate level Java programmers. This book will also be beneficial to a graduate student who is familiar with Java. Practicing software developers might use this book as their first foray into the Eclipse world. If you are a seasoned Java developer that has been using another IDE and wondering what Eclipse brings to the table, this book will provide you with a hands-on walkthrough of the main IDE features. Seasoned Eclipse users might not benefit from this book, since it is tailored to be an introduction on how to get started with Eclipse. Let's put it another way, this book can be seen as a first step towards mastering Eclipse; it is a fast-paced tutorial for those who want to hit the ground running and begin being productive with Eclipse right away.

If you are not familiar with Java, then this is not the book for you. If you have just been introduced to Java, you will be able to follow most of the content in this book after a crash course in Java syntax (just make sure you have a Java textbook close at hand.). For the most part, the chunks of Java code presented here are accessible to Java beginners. We tried to keep the code in the examples as simple as possible so that beginners will not be bogged down by technical details related to Java syntax. Whenever something a little bit more complex is shown, we provide an overview of it or we direct the reader to a more in-depth discussion of the to pic at hand.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: " The option to transform a for loop into an indexed for loop is available for expressions."

A block of code is set as follows:

@Test(timeout=1000)
public void testSquareRoot() {
   while(true);
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

@Test(timeout=1000)
public void testSquareRoot() {
   while(true);
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: " We strongly recommend you to download the Eclipse IDE for Java Developers.

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.