3

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?

Dan
  • 3,647
  • 5
  • 20
  • 26
Falk Oscar
  • 51
  • 2

2 Answers2

2

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.

Falk Oscar
  • 51
  • 2
0

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

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