Chapter 1. Getting Started: Compiling and Running Java
1.0 Introduction
This chapter covers some entry-level tasks that you need to know how to do before you can go on. It is said you must crawl before you can walk, and walk before you can ride a bicycle. Before you can try out anything in this book, you need to be able to compile and run your Java code, so I start there, showing several ways to do that: the JDK way, the Integrated Development Environment (IDE) way, and the build tools (Ant, Maven, etc.) way. Another issue people run into is setting CLASSPATH correctly, so that’s dealt with next. Deprecation warnings follow after that, because you’re likely to encounter them in maintaining old Java code. The chapter ends with some general information about conditional compilation, unit testing, assertions, and debugging.
If you don’t already have Java installed, you’ll need to download it. Be aware that there
are several different downloads. The JRE (Java Runtime Environment) was, up until Java 8, a smaller download for end users.
Since there is far less desktop Java than there once was, the JRE was eliminated in favor
of jlink to make a custom download (see Recipe 15.8).
The JDK or Java SDK download is the full development environment,
which you’ll want if you’re going to be developing Java software.
Standard downloads for the current release of Java are available at Oracle’s website.
You can sometimes find prerelease builds of the next major Java version on http://jdk.java.net ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access