10 releases
0.2.9 | Sep 25, 2021 |
---|---|
0.2.8 | Jul 30, 2021 |
0.2.7 | Mar 20, 2021 |
0.2.4 | Oct 23, 2020 |
0.1.0 | Sep 27, 2020 |
#140 in Build Utils
31 downloads per month
36KB
847 lines
java-preloader-reloadeder
Replacement for my old gist.
Downloads JDKs from Adoptium into <cache dir>/jpre/jdks
, then sets a symlink to the currently active JDK.
The symlinks are per-TTY (which usually implies per-shell), and stored in the Rust-std-determined temporary folder,
which is usually $TMPDIR
or /tmp
.
Installation
Run cargo install jpre
to get the jpre
binary, and set your JAVA_HOME
to $(jpre java-home)
.
For most people adding this is enough:
# Retrieves the TTY-specific path and stores it in JAVA_HOME. This will be symlinked to the currently active JDK.
export JAVA_HOME="$(jpre java-home)"
# Puts the binaries on your path
export PATH="$JAVA_HOME/bin:$PATH"
# Potentially optional, forces shell to re-scan for `java` et. al
hash -r
Note that if you do not set a default JDK, the symlinked path will lead nowhere!
Usage
Run jpre use 11
, this downloads JDK 11 from Adoptium and makes it the active JDK.
Other major versions can be downloaded and configured using jpre use <major>
.
The default JDK can be set using jpre default <major>
.
Full details are available by running jpre help
.
Known Limitations
Since this is per-TTY, closing and re-opening a terminal tab / window may result in a different JDK than the default, due to TTY reuse.
Dependencies
~7–14MB
~289K SLoC