2020-10-09 05:05:46 -06:00
|
|
|
# Example Source Code for the Book "On Java 8" by Bruce Eckel
|
|
|
|
|
2020-10-09 05:04:50 -06:00
|
|
|
Download release from [here](https://github.com/BruceEckel/OnJava8-Examples/releases/tag/v1.0).
|
|
|
|
|
2020-10-09 04:53:27 -06:00
|
|
|
To compile and run these programs, you only need JDK 8 installed.
|
2016-08-02 15:46:42 -06:00
|
|
|
Invoking `gradlew` will automatically download and install Gradle.
|
|
|
|
Gradle will also install all additional libraries necessary to compile
|
|
|
|
and run the Java examples in the book.
|
|
|
|
|
2016-11-23 12:31:35 -08:00
|
|
|
To compile and run everything, the command is:
|
2016-08-02 15:46:42 -06:00
|
|
|
|
2016-11-23 12:31:35 -08:00
|
|
|
`gradlew run`
|
2016-08-02 15:46:42 -06:00
|
|
|
|
2016-11-23 12:31:35 -08:00
|
|
|
If you are on a Unix/Linux based system, you must select the local directory for all commands, for example:
|
2016-08-02 15:46:42 -06:00
|
|
|
|
2016-11-23 12:31:35 -08:00
|
|
|
`./gradlew run`
|
|
|
|
|
|
|
|
To only compile everything, the command is:
|
|
|
|
|
|
|
|
`gradlew compileJava`
|
2016-08-02 15:46:42 -06:00
|
|
|
|
|
|
|
To compile only a single chapter (including dependencies), use for example:
|
|
|
|
|
2016-11-23 12:31:35 -08:00
|
|
|
`gradlew :strings:compileJava`
|
2016-08-02 15:46:42 -06:00
|
|
|
|
|
|
|
To run only a single chapter, say:
|
|
|
|
|
|
|
|
`gradlew :strings:run`
|
2016-08-02 15:52:30 -06:00
|
|
|
|
|
|
|
Gradle can also be used to run a single program. Here, we run the **ReplacingStringTokenizer.java**
|
|
|
|
program in the **strings** chapter subdirectory:
|
|
|
|
|
|
|
|
`gradlew :strings:ReplacingStringTokenizer`
|
|
|
|
|
|
|
|
However, if the file name is unique throughout the book (the majority are), you can just give the
|
|
|
|
program name, like this:
|
|
|
|
|
|
|
|
`gradlew ReplacingStringTokenizer`
|
|
|
|
|
2016-11-23 12:31:35 -08:00
|
|
|
Note that all commands are run from the base directory where the example code is installed, and where you find the
|
2016-08-02 15:52:30 -06:00
|
|
|
`gradlew` script.
|
2016-08-02 15:53:45 -06:00
|
|
|
|
|
|
|
You can learn about other options by just typing `gradlew` with no arguments.
|