Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run SDKMAN on shell script

Tags:

shell

sh

sdkman

I am trying to run sdkman on a shell script that I call run.sh. This is what the inside of the shell script looks like:

sdk use java 8.0.302-open

When I run the command in a terminal, it works. But when I run it in a shell script, I get this error:

run.sh: 1: sdk: not found

Anyone knows how to fix this?

like image 282
Falk Oscar Avatar asked Sep 08 '26 14:09

Falk Oscar


2 Answers

I fixed it for me; Although this may not work for others.

I placed #!/bin/bash at the top of the shell script, and then added this after it:

source "$HOME/.sdkman/bin/sdkman-init.sh"

Then my shell script was able to be ran using:

./run.sh

sdkman was able to work this time.

like image 200
Falk Oscar Avatar answered Sep 12 '26 04:09

Falk Oscar


I have a MAC and fixed it adding this line below #!/bin/bash:

. /Users/myuser/.sdkman/bin/sdkman-init.sh

like image 28
Eder Armando Anillo Lora Avatar answered Sep 12 '26 02:09

Eder Armando Anillo Lora



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!