Although it’s possible to write, compile, and run Java
applications with nothing more than Oracle’s Java Development
Kit (JDK) and a simple text editor (e.g., vi, Notepad, etc.),
today the vast majority of Java code is written with the benefit of an
Integrated Development Environment (IDE). The
benefits of using an IDE include an all-in-one view of Java source code
with syntax highlighting, navigation help, source control, integrated documentation, building,
refactoring, and deployment all at your fingertips. Therefore, we are
going to skip an academic command-line treatment and start with the most
popular IDE, Eclipse. If you are adverse to using an IDE, feel free to use
the command-line instructions javac HelloJava.java
for
compilation and java HelloJava
to run the upcoming
examples.
IBM originally spearheaded The Eclipse Project in 2001, leading a consortium of software vendors to create an open and extensible development environment to rival the then-legendary Visual Studio environment from Microsoft. Today, Eclipse has grown into a powerful open source platform supported by individuals and corporations alike, backed by a thriving ecosystem of plug-ins and frameworks. Although Java is the most popular language associated with Eclipse, the IDE supports dozens of languages. We will be doing a light introduction to Eclipse in this chapter. For a more comprehensive approach, see Appendix A.
Eclipse requires a Java Runtime
Environment (JRE) to be installed. This book covers Java 7
language features, so although the examples in this chapter will work with
older versions, it’s best to have JDK 7 installed to ensure that all
examples in the book compile. The JDK includes the JRE as well as
developer tools. You can check to see which version, if any, you have
installed by typing java -version
at the command line. If
Java isn’t present, or if it’s a version older than JDK 7 (confusingly
also referred to as JDK 1.7), you will want to download the latest version
from Oracle’s
download page. All that is required for the examples in this book
is the basic JDK, which is the first option in the upper-left corner of
the download page.
Eclipse is an open source IDE available at Eclipse.org. For the purposes of this book, and getting started with Java in general, the Eclipse Classic download is sufficient. Make sure the architecture of your JDK and Eclipse matches. In other words, don’t use a 64-bit JDK with a 32-bit version of Eclipse or vice versa. The download is a compressed archive: .zip for Windows and .tar.gz on OS X and Linux. Double-click to expand and run the installer.
Get Learning Java, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.