Having SDKMAN! installed (http://sdkman.io/), I can install packages from the command line using for example:
sdk install java 8u144-zulu
However, when I try to do the same thing from within a script "my-installer.sh", I get error message: "sdk: command not found".
my-installer.sh:
#!/bin/bash
sdk install java 8u144-zulu
What am I doing wrong?
The installed SDKs are stored in the SDKMAN! directory which defaults to ~/. sdkman/candidates.
SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.
you need to source in ~/.sdkman/bin/sdkman-init.sh, like in
#!/bin/bash
. /home/alexw/.sdkman/bin/sdkman-init.sh
sdk install java 8u144-zulu
'sdk' is a bash function declared in sdkman-init.sh, and your first line (#!...) starts a new(!) shell.
hope that helps! weHe
Here's how to source sdkman-init.sh
more generically:
source "$HOME/.sdkman/bin/sdkman-init.sh"
This is similar to the code that SDKMAN adds to your .zshrc
file:
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/powers/.sdkman"
[[ -s "/Users/powers/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/powers/.sdkman/bin/sdkman-init.sh"
Type which sdk
if you'd like to see the function that's being sourced:
sdk () {
COMMAND="$1"
QUALIFIER="$2"
case "$COMMAND" in
(l) COMMAND="list" ;;
(ls) COMMAND="list" ;;
(v) COMMAND="version" ;;
(u) COMMAND="use" ;;
...
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With