### Install Default JDK on Ubuntu/Debian Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md These commands update the package lists and then install the default Java Development Kit package on Ubuntu or Debian-based Linux systems using APT. This provides the necessary Java environment for compiling and running the book examples. ```Shell sudo apt-get update ``` ```Shell sudo apt-get install default-jdk ``` -------------------------------- ### Run Book Examples Tests with Gradle Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md These commands execute the test suite for the 'On Java 8' book examples using Gradle. An internet connection is required for the first run to install Gradle and its dependencies. On Mac/Linux, ensure the `gradlew` script has execute permissions; if 'Permission denied' occurs, run `chmod +x ./gradlew` first. ```Shell ./gradlew test ``` ```Windows Batch gradlew test ``` -------------------------------- ### Running Gradle Tests for Book Examples Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Instructions to execute the test suite for the book's Java examples using Gradle. This command initiates the build process and runs all defined tests. The first execution will download necessary dependencies and may take time, requiring an internet connection. ```Shell gradlew test ``` ```Shell ./gradlew test ``` -------------------------------- ### Install JDK 8 on Windows with Chocolatey Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md This command uses Chocolatey, a package manager for Windows, to install Java Development Kit version 8. It handles the installation process and sets necessary environment variables. ```Windows Batch choco install jdk8 ``` -------------------------------- ### Install Java on macOS with HomeBrew Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md These commands use HomeBrew, the package manager for macOS, to install Java. First, update HomeBrew, then install Java. This is necessary to update from older pre-installed Java versions. ```Shell brew update ``` ```Shell brew cask install java ``` -------------------------------- ### Verify Java Installation Version Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md This command displays the installed Java Development Kit (JDK) or Java Runtime Environment (JRE) version information. It's used to confirm a successful Java installation and check the active Java version. ```Shell java -version ``` -------------------------------- ### Install OpenJDK 8 on Fedora/Redhat with Yum Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md This command uses the Yum package manager to install OpenJDK version 1.8.0 on Fedora or Redhat-based Linux systems. The `su -c` prefix executes the command as the superuser. ```Shell su -c "yum install java-1.8.0-openjdk" ``` -------------------------------- ### Gradle: Compile and Run All Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Compile and execute all code in the project. Run from the base directory. ```Gradle gradlew run ./gradlew run ``` -------------------------------- ### Shell: Create Directory Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Make a new directory. `mkdir` is for Mac/Linux, `md` for Windows, followed by the desired name. ```Shell (Mac/Linux) mkdir mkdir books ``` ```Shell (Windows) md md books ``` -------------------------------- ### Gradle: Display Help Options Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Display available Gradle tasks and options. Running `gradlew` without arguments provides a list of commands. ```Gradle gradlew ``` -------------------------------- ### Gradle: Run Project Tests Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Execute all tests in the project. Run from the base directory. ```Gradle gradlew test ./gradlew test ``` -------------------------------- ### Gradle: Run Single Chapter Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Execute the main program within a specific chapter. Example runs the 'strings' chapter. ```Gradle gradlew :strings:run ``` -------------------------------- ### Shell: List Directory Contents Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Display files and subdirectories. `ls` is for Mac/Linux, `dir` for Windows. Wildcards (`*`) can filter results. ```Shell (Mac/Linux) ls ls *.kt ls F*.kt ``` ```Shell (Windows) dir dir *.kt dir F*.kt ``` -------------------------------- ### Gradle: Compile All Java Code Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Compile all Java source files in the project. Run from the base directory. ```Gradle gradlew compileJava ``` -------------------------------- ### Gradle: Compile Single Chapter Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Compile code for a specific chapter, including dependencies. Example compiles the 'strings' chapter. ```Gradle gradlew :strings:compileJava ``` -------------------------------- ### Shell: Remove File Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Delete a file. `rm` is for Mac/Linux, `del` for Windows, followed by the file name. ```Shell (Mac/Linux) rm rm somefile.kt ``` ```Shell (Windows) del del somefile.kt ``` -------------------------------- ### Shell: View Command History Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Access a list of previously entered commands. `history` is for Mac/Linux, F7 key for Windows. Mac/Linux history includes numbers for re-execution. ```Shell (Mac/Linux) history ``` ```Shell (Windows) # Press F7 key ``` -------------------------------- ### Shell: Change Directory Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Navigate between directories. `cd ` moves into a specified directory, `cd ..` moves up one level. `pushd` and `popd` allow temporary directory changes with easy return. ```Shell cd cd .. pushd popd ``` -------------------------------- ### Gradle: Run Specific Program by Full Path Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Run a single program by specifying its full path within the project structure. This is useful for programs not unique by name. ```Gradle gradlew :strings:ReplacingStringTokenizer ``` -------------------------------- ### Shell: Remove Directory Recursively Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Delete a directory and its contents. `rm -r` is for Mac/Linux, `deltree` for Windows, followed by the directory name. ```Shell (Mac/Linux) rm -r rm -r books ``` ```Shell (Windows) deltree deltree books ``` -------------------------------- ### Gradle: Run Specific Program by Unique Name Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Run a single program by its name, assuming the name is unique across the entire project. This simplifies execution. ```Gradle gradlew ReplacingStringTokenizer ``` -------------------------------- ### Shell: Repeat Previous Commands Source: https://github.com/bruceeckel/onjava8-examples/blob/master/README.md Methods to re-execute past commands. The 'up arrow' key works universally. Mac/Linux offer `!!` for the last command and `!n` for the nth command. ```Shell # Use up arrow key ``` ```Shell (Mac/Linux) !! !n ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.