### Install a Specific Java Version Source: https://context7.com/halcyon/asdf-java/llms.txt Downloads and installs a chosen JDK version, automatically verifying its checksum. Supports various distributions and versioning schemes. ```bash # Install a specific version asdf install java temurin-17.0.4+8 # Install AdoptOpenJDK 11 asdf install java adoptopenjdk-11.0.16+8 # Install the latest version of a distribution asdf install java latest:temurin-17 # Install GraalVM with Java 17 asdf install java graalvm-22.2.0+java17 # Install Amazon Corretto asdf install java corretto-17.0.4.8.1 ``` -------------------------------- ### Install a Specific Java Version Source: https://github.com/halcyon/asdf-java/blob/master/README.md Install a specific JDK version by providing its identifier, which can be obtained from `asdf list all java`. Ensure the version string is accurate. ```bash asdf install java adoptopenjdk-11.0.16+8 ``` -------------------------------- ### Example .tool-versions File Content Source: https://github.com/halcyon/asdf-java/blob/master/README.md This shows the content of the `.tool-versions` file after setting the latest Java version for a major release. It reflects the resolved specific version. ```shell java adoptopenjdk-11.0.16+8 ``` -------------------------------- ### List Available Java Versions Source: https://github.com/halcyon/asdf-java/blob/master/README.md Run this command to see all the Java Development Kit (JDK) versions that are available for installation through the asdf-java plugin. ```bash asdf list all java ``` -------------------------------- ### List Installed Java Versions Source: https://context7.com/halcyon/asdf-java/llms.txt Displays all Java versions currently installed locally by the asdf-java plugin. The active version is marked with an asterisk. ```bash # List all installed Java versions asdf list java # Example output: # adoptopenjdk-11.0.16+8 # temurin-17.0.4+8 # *zulu-11.58.15 # (* indicates currently active version) ``` -------------------------------- ### List Available Java Versions Source: https://context7.com/halcyon/asdf-java/llms.txt Displays all installable JDK versions compatible with your OS and architecture. Supports filtering by distribution or version number. ```bash # List all available Java versions asdf list all java # Example output (truncated): # adoptopenjdk-11.0.16+8 # adoptopenjdk-17.0.4+8 # corretto-11.0.16.8.1 # corretto-17.0.4.8.1 # graalvm-22.2.0+java11 # graalvm-22.2.0+java17 # temurin-11.0.16+8 # temurin-17.0.4+8 # zulu-11.58.15 # zulu-17.36.13 # Filter by distribution prefix asdf list all java | grep temurin # Output: # temurin-11.0.16+8 # temurin-17.0.4+8 # temurin-18.0.2+9 # temurin-19.0.0+36 # Filter by Java version asdf list all java | grep "17\." ``` -------------------------------- ### Add asdf-java Plugin Source: https://github.com/halcyon/asdf-java/blob/master/README.md Use this command to add the asdf-java plugin to your asdf installation. This is the first step before managing Java versions. ```bash asdf plugin add java https://github.com/halcyon/asdf-java.git ``` -------------------------------- ### Enable macOS JAVA_HOME Integration Source: https://context7.com/halcyon/asdf-java/llms.txt Add `java_macos_integration_enable=yes` to `~/.asdfrc` to integrate with macOS's `/usr/libexec/java_home` utility. Optionally set `java_macos_integration_in_home=yes` to install JDKs to the user's Library directory without requiring sudo. ```bash # Add to ~/.asdfrc java_macos_integration_enable=yes # Optionally install to user Library instead of system (no sudo required) java_macos_integration_in_home=yes # After installing a JDK, it will be registered with macOS asdf install java zulu-17.36.13 # Verify with java_home utility /usr/libexec/java_home -V ``` ```text # Output: # Matching Java Virtual Machines (2): # 17.0.4 (x86_64) "Azul Systems, Inc." - "Zulu 17.36.13" /Library/Java/JavaVirtualMachines/zulu-17.36.13/Contents/Home # 11.0.16 (x86_64) "Eclipse Adoptium" - "Temurin-11.0.16+8" /Library/Java/JavaVirtualMachines/temurin-11.0.16+8/Contents/Home ``` ```bash # Use java_home to get specific version /usr/libexec/java_home -v 17 ``` ```text # Output: /Library/Java/JavaVirtualMachines/zulu-17.36.13/Contents/Home ``` -------------------------------- ### Install Latest Java Version of a Major Release Source: https://github.com/halcyon/asdf-java/blob/master/README.md Install the latest available patch version for a specific major Java release (e.g., Java 11). This simplifies managing the most recent updates. ```bash asdf install java latest:adoptopenjdk-11 ``` -------------------------------- ### Source JAVA_HOME Fish Script Source: https://github.com/halcyon/asdf-java/blob/master/README.md For Fish shell users, add this line to your configuration to set the JAVA_HOME environment variable for asdf-managed Java installations. ```fish source ~/.asdf/plugins/java/set-java-home.fish ``` -------------------------------- ### JAVA_HOME Shell Integration (Fish) Source: https://context7.com/halcyon/asdf-java/llms.txt Provides automatic JAVA_HOME updates for Fish shell users. Source the provided script in your ~/.config/fish/config.fish. ```fish # Add to ~/.config/fish/config.fish source ~/.asdf/plugins/java/set-java-home.fish # JAVA_HOME updates on each prompt cd ~/java-project echo $JAVA_HOME # Output: /home/user/.asdf/installs/java/temurin-17.0.4+8 ``` -------------------------------- ### Enable macOS JAVA_HOME Integration Source: https://github.com/halcyon/asdf-java/blob/master/README.md Set this option in your `.asdfrc` file to enable integration with macOS's `/usr/libexec/java_home` utility. Note that this only works for Java distributions that support this integration. ```ini java_macos_integration_enable=yes ``` -------------------------------- ### JAVA_HOME Shell Integration (Bash) Source: https://context7.com/halcyon/asdf-java/llms.txt Automatically sets JAVA_HOME and JDK_HOME environment variables upon directory changes for Bash users. Add the provided line to your ~/.bashrc. ```bash # Add to ~/.bashrc . ~/.asdf/plugins/java/set-java-home.bash # After sourcing, JAVA_HOME updates automatically on directory change cd ~/project-with-java11 echo $JAVA_HOME # Output: /home/user/.asdf/installs/java/adoptopenjdk-11.0.16+8 cd ~/project-with-java17 echo $JAVA_HOME # Output: /home/user/.asdf/installs/java/temurin-17.0.4+8 # JDK_HOME is also set echo $JDK_HOME # Output: /home/user/.asdf/installs/java/temurin-17.0.4+8 ``` -------------------------------- ### JAVA_HOME Shell Integration (Zsh) Source: https://context7.com/halcyon/asdf-java/llms.txt Enables automatic JAVA_HOME updates for Zsh users by integrating with the precmd hook. Add the provided line to your ~/.zshrc. ```zsh # Add to ~/.zshrc . ~/.asdf/plugins/java/set-java-home.zsh # Uses zsh precmd hook to update on each prompt cd ~/java-project echo $JAVA_HOME # Output: /home/user/.asdf/installs/java/temurin-17.0.4+8 ``` -------------------------------- ### Support for Legacy Version Files Source: https://context7.com/halcyon/asdf-java/llms.txt The asdf-java plugin automatically recognizes and uses `.java-version` files, which were commonly used by other Java version managers. This facilitates easy migration to asdf. ```bash # If you have an existing .java-version file cat .java-version ``` ```text # Output: adoptopenjdk-11.0.16+8 ``` ```bash # asdf-java will recognize and use it asdf current java ``` ```text # Output: java adoptopenjdk-11.0.16+8 /path/to/project/.java-version ``` -------------------------------- ### JAVA_HOME Shell Integration (Nushell) Source: https://context7.com/halcyon/asdf-java/llms.txt Enables automatic JAVA_HOME updates for Nushell users. Source the script in your configuration and call the update function. ```nu # Source in your config source ~/.asdf/plugins/java/set-java-home.nu # Call manually or set up as hook asdf_update_java_home # Check the result $env.JAVA_HOME ``` -------------------------------- ### Source JAVA_HOME NuShell Script Source: https://github.com/halcyon/asdf-java/blob/master/README.md Integrate JAVA_HOME setting for NuShell by sourcing this script from your NuShell configuration. ```powershell source ~/.asdf/plugins/java/set-java-home.nu ``` -------------------------------- ### Set Global or Local Java Version Source: https://context7.com/halcyon/asdf-java/llms.txt Configures the active Java version globally or for the current project directory. Supports 'latest' syntax for automatic resolution. ```bash # Set global Java version (all directories) asdf set -u java temurin-17.0.4+8 # Set local Java version (current directory only) asdf set java adoptopenjdk-11.0.16+8 # This creates a .tool-versions file: cat .tool-versions # Output: java adoptopenjdk-11.0.16+8 # Use latest syntax for automatic resolution asdf set java latest:temurin-17 # Resolves to actual version in .tool-versions: cat .tool-versions # Output: java temurin-17.0.4+8 # Verify current version asdf current java # Output: java temurin-17.0.4+8 /home/user/.tool-versions ``` -------------------------------- ### Source JAVA_HOME Xonsh Script Source: https://github.com/halcyon/asdf-java/blob/master/README.md Xonsh users can set the JAVA_HOME environment variable by sourcing this script within their Xonsh configuration. ```bash source ~/.asdf/plugins/java/set-java-home.xsh ``` -------------------------------- ### Set Global Java Version Source: https://github.com/halcyon/asdf-java/blob/master/README.md Set the default Java version for your entire system. This command updates the global asdf configuration. ```bash asdf set -u java adoptopenjdk-11.0.16+8 ``` -------------------------------- ### Set Local Java Version Source: https://github.com/halcyon/asdf-java/blob/master/README.md Set the Java version for the current directory and its subdirectories. This is useful for project-specific Java requirements. ```bash asdf set java adoptopenjdk-11.0.16+8 ``` -------------------------------- ### Configure Java Release Types Source: https://context7.com/halcyon/asdf-java/llms.txt Control which release types (GA, EA, or all) are shown when listing available Java versions by setting the `java_release_type` option in `~/.asdfrc`. The default is `ga` (stable releases only). ```bash # Show only GA releases (default) echo 'java_release_type=ga' >> ~/.asdfrc # Show only EA (early access/beta) releases echo 'java_release_type=ea' >> ~/.asdfrc # Show all releases (GA + EA) echo 'java_release_type=all' >> ~/.asdfrc # After changing, the list-all output will reflect the setting asdf list all java ``` -------------------------------- ### Source JAVA_HOME Bash Script Source: https://github.com/halcyon/asdf-java/blob/master/README.md Add this line to your shell's initialization file (e.g., `.bashrc`, `.zshrc`) to automatically set the JAVA_HOME environment variable based on the asdf-managed Java version. ```bash . ~/.asdf/plugins/java/set-java-home.bash ``` -------------------------------- ### Switch Terminal to Rosetta for x86_64 on Apple Silicon Source: https://github.com/halcyon/asdf-java/blob/master/README.md On Apple Silicon Macs, use this command to switch your current terminal session to run under Rosetta 2 emulation, allowing you to use x86_64 Java versions. ```bash arch -x86_64 /bin/zsh ``` -------------------------------- ### Source JAVA_HOME Zsh Script Source: https://github.com/halcyon/asdf-java/blob/master/README.md Use this command in your `.zshrc` file to set the JAVA_HOME environment variable for Zsh users managing Java versions with asdf. ```zsh . ~/.asdf/plugins/java/set-java-home.zsh ``` -------------------------------- ### Uninstall a Java Version Source: https://context7.com/halcyon/asdf-java/llms.txt Use the `asdf uninstall` command to remove a specific Java version. If macOS integration is enabled, this command also removes the JDK's registration from the system's Java Virtual Machines directory. ```bash # Uninstall a specific version asdf uninstall java adoptopenjdk-11.0.16+8 # On macOS with java_macos_integration_enable=yes, # this also removes from /Library/Java/JavaVirtualMachines/ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.