{"id":13547259,"url":"https://github.com/michaelklishin/jdk_switcher","last_synced_at":"2025-04-10T17:40:44.805Z","repository":{"id":3408003,"uuid":"4458265","full_name":"michaelklishin/jdk_switcher","owner":"michaelklishin","description":"A yet another Ubuntu/Debian-specific tool that makes switching between multiple JDK versions a one liner","archived":false,"fork":false,"pushed_at":"2019-08-12T08:34:04.000Z","size":39,"stargazers_count":74,"open_issues_count":4,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-10T07:59:01.954Z","etag":null,"topics":["debian","java","openjdk","ubuntu","version-manager"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelklishin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-26T22:23:28.000Z","updated_at":"2024-10-31T23:44:40.000Z","dependencies_parsed_at":"2022-08-30T06:11:23.508Z","dependency_job_id":null,"html_url":"https://github.com/michaelklishin/jdk_switcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelklishin%2Fjdk_switcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelklishin%2Fjdk_switcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelklishin%2Fjdk_switcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelklishin%2Fjdk_switcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelklishin","download_url":"https://codeload.github.com/michaelklishin/jdk_switcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262170,"owners_count":21074256,"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":["debian","java","openjdk","ubuntu","version-manager"],"created_at":"2024-08-01T12:00:53.098Z","updated_at":"2025-04-10T17:40:44.790Z","avatar_url":"https://github.com/michaelklishin.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# What JDK switcher is\n\nThis is a yet another Ubuntu/Debian-specific script that switches between multiple JDK\nversions (including those that may not have been installed via apt).\n\nIt is meant to be used in the [travis-ci.org CI environment](https://github.com/travis-ci/travis-cookbooks) but\nmay be useful in other environments, too.\n\n## Usage\n\nInstall one or more JDKs that register themselves with the `update-java-alternatives` tools by\ninstalling a `.jinfo` file under `/usr/lib/jvm`.\n\nThen source `jdk_switcher.sh` in the repository root and use the `jdk_switcher` function it two arguments,\na command and the JDK to use:\n\n``` bash\n. ./jdk_switcher.sh\n\njdk_switcher home oraclejdk10\n\njdk_switcher  use openjdk7\n\njdk_switcher home ibmjdk8\n```\n\n### Commands\n\n * `use`: switches active JDK (updates `PATH` alternatives and exports `JAVA_HOME`)\n * `home`: prints `JAVA_HOME` value for the specified JDK. Does not change anything in the environment.\n\n### JDK aliases\n\nSupported aliases are:\n\n * `oraclejdk10`\n * `oraclejdk8`\n * `oraclejdk7`\n * `openjdk7`\n * `openjdk6`\n * `ibmjdk8`\n\n\n## How Does it Work?\n\nThe switcher uses [update-java-alternatives](http://manpages.ubuntu.com/manpages/hardy/man8/update-java-alternatives.8.html) (see also [this intro](http://wiki.debian.org/Java/#Java_and_Debian)) under the hood to update `/etc/alternatives/*` symlinks for\n`java`, `javac`, `javap` and other JDK tools. As such, the switcher itself primary handles aliasing of\nJDKs (`update-java-alternatives` aliases are too hard to remember) and updating `JAVA_HOME` value.\n\n`JAVA_HOME` changes is the reason why `jdk_switcher` is implemented as a function.\n\n\n## Why was this tool necessary?\n\n`JAVA_HOME` updates is the key reason for it to exist: `update-java-alternatives` and related Debian tools\nin general do a great job of managing alternatives but won't touch or even define `JAVA_HOME`. Even though most\nJVM ecosystem tools (from Leiningen to Elastic Search, HBase and Cassandra) will\ntry hard to detect `JAVA_HOME` value but unfortunately, Maven 3 does it in a way that is heavily biased\ntowards OpenJDK 6.\n\nFor travis-ci.org to support multiple JDKs for Clojure, Groovy, Java, Scala and JRuby, it is crucially\nimportant that all the tools we provision will use the JDK version specified for a build. We cannot let\nMaven always use OpenJDK 6.\n\n\n\n## License \u0026 Copyright\n\nMIT LICENSE\n\nCopyright (c) 2012-2019 Michael S. Klishin and Travis CI Development Team\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelklishin%2Fjdk_switcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelklishin%2Fjdk_switcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelklishin%2Fjdk_switcher/lists"}