{"id":28325615,"url":"https://github.com/dameikle/javalocate","last_synced_at":"2025-06-23T15:31:33.409Z","repository":{"id":62441282,"uuid":"465917126","full_name":"dameikle/javalocate","owner":"dameikle","description":"Command line utility to find JVM versions on macOS, Linux and Windows","archived":false,"fork":false,"pushed_at":"2023-12-06T12:33:09.000Z","size":34,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-02T06:20:39.108Z","etag":null,"topics":["command-line","java","linux","macos","rust","windows"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dameikle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-03T23:27:32.000Z","updated_at":"2023-10-03T04:49:34.000Z","dependencies_parsed_at":"2022-11-01T22:01:56.512Z","dependency_job_id":null,"html_url":"https://github.com/dameikle/javalocate","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/dameikle/javalocate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dameikle%2Fjavalocate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dameikle%2Fjavalocate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dameikle%2Fjavalocate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dameikle%2Fjavalocate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dameikle","download_url":"https://codeload.github.com/dameikle/javalocate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dameikle%2Fjavalocate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261504175,"owners_count":23168770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","java","linux","macos","rust","windows"],"created_at":"2025-05-25T21:14:00.173Z","updated_at":"2025-06-23T15:31:33.400Z","avatar_url":"https://github.com/dameikle.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# javalocate\n[![license](https://img.shields.io/github/license/dameikle/javalocate.svg?maxAge=2592000)](https://github.com/dameikle/javalocate/blob/main/LICENSE)\n[![Crates.io](https://img.shields.io/crates/v/javalocate)](https://crates.io/crates/javalocate)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/dameikle/javalocate)](https://github.com/dameikle/javalocate/releases)\n[![ubuntu build](https://github.com/dameikle/javalocate/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/dameikle/javalocate/actions)\n[![windows build](https://github.com/dameikle/javalocate/actions/workflows/windows.yml/badge.svg)](https://github.com/dameikle/javalocate/actions)\n[![macOS build](https://github.com/dameikle/javalocate/actions/workflows/macos.yml/badge.svg)](https://github.com/dameikle/javalocate/actions)\n\nCommand line utility to find JVM versions on macOS, Linux (Debian, Ubuntu, RHEL/CentOS \u0026 Fedora) and Windows - useful \nfor setting _JAVA_HOME_, particularly on machines with different JVM versions and architectures. \n\nI'm thinking of you, Java Devs with Apple Silicon hardware 🐱‍💻\n\n## Install\n\nThe utility can be installed using Homebrew via the [homebrew-javalocate](https://github.com/dameikle/homebrew-javalocate) tap:\n```bash\nbrew tap dameikle/javalocate\nbrew install javalocate\n```\nOr using Cargo via the [javalocate](https://crates.io/crates/javalocate) crate on crates.io:\n```bash\ncargo install javalocate\n```\n\n## Usage\n\nThe utility is designed to be used in a similar fashion to the _/usr/libexec/java_home_ by providing \na number of flags that can be passed to control the selection.\n\nThese are shown below:\n\n```\nOPTIONS:\n    -a, --arch \u003cARCH\u003e                   Architecture to filter on (e.g. x86_64, aarch64, amd64)\n    -d, --detailed                      Print out full details\n    -f, --fail                          Return error code if no JVM found\n    -h, --help                          Print help information\n    -n, --name \u003cNAME\u003e                   JVM Name to filter on\n    -v, --version \u003cVERSION\u003e             Version to filter on (e.g. 1.8, 11, 17, etc)\n    -r, --register-location \u003cLOCATION\u003e  Registers a custom JVM location directory to search in\n    -x, --remove-location \u003cLOCATION\u003e    Removes a registered custom JVM location directory\n    -l, --display-locations             Displays all the custom JVM location directories that are registered\n```\n\n### Outputs\nBy default, the utility outputs a single path location to the \"top\" JVM found, ordered by descending version (i.e. Java 17 \u003e Java 8), \nprioritising the system architecture (i.e. aarch64 \u003e x86_64 on a Apple Silicon Mac).\n\nPassing the detailed flag (_--detailed_ or _-d_) prints the full details of all JVMs found.\n\nThis flag can also be used in conjunction with filters to display full details for the filtered set.\n\n### Filtering\n\nThe filtering options of _name_, _version_ and _arch_ can be used in isolation or together to fine tune the selection.\n\nFor example, to get the path to Java 17\n```bash\njavalocate -v 17\n```\n\nOr to get the path to the x86_64 JVM for Java 11 \n```bash\njavalocate -v 11 -a x86_64\n```\n\nOr to get the path to latest aarch64 JVM available\n```bash\njavalocate -a aarch64\n```\n\nYou can also specify a minimum version by appending a _+_ to the version:\n```bash\njavalocate -v 1.8+\n```\n\n### Exit Code\n\nBy default, the utility returns an OK (0) exit code whether a JVM is found or not.\n\nSetting the fail flag (_--fail or _-f_) changes this behaviour, returning a CONFIG ERROR (78) exit code.\n\nThis can be useful if you want to use the utility in a shell script.\n\nFor example, the below would return an error code if Java 11 or above could not be found when trying to set the _JAVA_HOME_ environment variable:\n```bash\nexport JAVA_HOME=$(javalocate -v 11+ -f)\n```\n\n## Default Locations\n\nThe utility looks in the default JVM installation locations for the following operating systems:\n\n| Operating System | Location                               |\n|------------------|----------------------------------------|\n| macOS            | /Library/Java/JavaVirtualMachines      |\n| Ubuntu           | /usr/lib/jvm                           |\n| Debian           | /usr/lib/jvm                           |\n| RHEL             | /usr/lib/jvm                           |\n| CentOS           | /usr/lib/jvm                           |\n| Fedora           | /usr/lib/jvm                           |\n| Windows          | Registry - HKEY_LOCAL_MACHINE\\Software |\n\nIt assumes that the _release_ file is included in the JVM package on Linux and Windows, and the _release_ file and\n_Info.plist_ file is packaged on macOS.\n\nExperimental support has been added to build information from path file name where _release_ file is not available. This\ncan occur on older JVMs.\n\n## Custom Locations\n\nYou can add your own locations to search in using the Custom JVM Location options. This can be useful\nif you maintain your own manually installed JVM collections.\n\nFor example, if you manually install JVMs into the the _/opt/jvms_ directory you can configure it to \nbe searched using the _--register-location_ (-r) command:\n```bash\njavalocate -r /opt/jvms\njavalocate --register-location /opt/jvms\n```\n\nIf you want to then remove that location, you can use the _--remove-location_ (-x) command:\n```bash\njavalocate -x /opt/jvms\njavalocate --remove-location /opt/jvms\n```\n\nYou can list the currently registered location using the _--display-locations_ (-l) command:\n```bash\njavalocate -l\njavalocate --display-locations\n```\n\n## Tips and Tricks\n\n### Bash Alias\n\nAdding the following to your _~/.bashrc_ (or _~/.bash_aliases_) file:\n\n```bash\nsetjava() {\n    export JAVA_HOME=`javalocate -v $1`\n}\n```\n\nAllows you to quickly flip between versions:\n```bash\nsetjava 17\necho $JAVA_HOME\nsetjava 8\necho $JAVA_HOME\nsetjava 11\necho $JAVA_HOME\n```\n\n### Powershell\nYou can set the version required in Powershell using the following syntax:\n```powershell\n$env:JAVA_HOME=$(javalocate.exe -v 11)\n```\n\n## Building\n\nThe utility is developed in Rust and can be build from source using:\n\n```\ncargo build\n```\n\nOr for a release version\n```\ncargo build --profile release\n```\n\n## Licence\nCopyright 2022 David Meikle\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdameikle%2Fjavalocate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdameikle%2Fjavalocate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdameikle%2Fjavalocate/lists"}