sdkman / sdkman-cli

The SDKMAN! Command Line Interface
https://sdkman.io
Apache License 2.0
6.12k stars 630 forks source link

Bug: No java runtime present, requesting install #760

Open edmondop opened 4 years ago

edmondop commented 4 years ago

Using SDKMAN on Catalina yields a strange result with some old applications such as Talend:

/Users/ed/Development/TOS_DI-20170623_1246-V6.4.1/TOS_DI-macosx-cocoa.app/Contents/MacOS/TOS_DI-macosx-cocoa
No Java runtime present, requesting install.

but the jdk is clearly available:

sdk home java 8.0.202-zulu /Users/ed/.sdkman/candidates/java/8.0.202-zulu

○ echo $JAVA_HOME /Users/ed/.sdkman/candidates/java/current

marc0der commented 4 years ago

Hi @edmondo1984, have you tried opening a new terminal and tried using the command again? Is this happening for all commands depending on Java? Anything else off significance?

In future, please use the provided template (the good stuff you deleted) when submitting bug reports, otherwise we simply don't have enough to go on and can't help.

agilob commented 4 years ago

I'm having the same or very similar issue on archlinux with oh-my-zsh.

Multiple java versions are installed, but none of them is available.

I think the problem is JAVA_HOME is incorrectly set at some point?

❯ sdk install java

Downloading: java 11.0.7.hs-adpt

In progress...

############################################################################################################################################################################################################# 100.0%############################################################################################################################################################################################################# 100.0%

Repackaging Java 11.0.7.hs-adpt...

Done repackaging...

Installing: java 11.0.7.hs-adpt
Done installing!

Do you want java 11.0.7.hs-adpt to be set as default? (Y/n): y

Setting java 11.0.7.hs-adpt as default.
❯ which java
java not found
❯ echo $JAVA_HOME
/home/agilob/.sdkman/candidates/java/current
❯ cd $JAVA_HOME/bin
❯ ls
jaotc  jarsigner  javac    javap  jconsole  jdeprscan  jfr    jimage  jjs    jmap  jps         jshell  jstat   keytool  rmic  rmiregistry  unpack200
jar    java       javadoc  jcmd   jdb       jdeps      jhsdb  jinfo   jlink  jmod  jrunscript  jstack  jstatd  pack200  rmid  serialver
❯ cd
❯ java
zsh: command not found: java
❯ sdk use java 11.0.7.hs-adpt

Using java version 11.0.7.hs-adpt in this shell.
❯ java
Usage: java [options] <mainclass> [args...]
...
JAVA FOUND NOW
...

Open another shell

❯ java
zsh: command not found: java
❯ sdk default java 11.0.7.hs-adpt

Default java version set to 11.0.7.hs-adpt
❯ java
zsh: command not found: java
❯ sdk use java 11.0.7.hs-adpt

Using java version 11.0.7.hs-adpt in this shell.
❯ java
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
JAVA FOUND again

It looks like sdk default doesnt set correct path leading to /java/@current

New shell

❯ sdk default java 11.0.7.hs-adpt

Default java version set to 11.0.7.hs-adpt
❯ java
zsh: command not found: java
❯ which java
java not found
❯ echo $JAVA_HOME
/home/agilob/.sdkman/candidates/java/current

New shell:

❯ sdk use java 11.0.7.hs-adpt

Using java version 11.0.7.hs-adpt in this shell.
❯ java
Usage: java [options] <mainclass> [args...]

❯ echo  $JAVA_HOME
/home/agilob/.sdkman/candidates/java/11.0.7.hs-adpt
❯ sdk version

SDKMAN 5.8.2+493

❯ zsh --version
zsh --version
zsh 5.8 (x86_64-pc-linux-gnu)
agilob commented 4 years ago

I can reproduce it with 14.0.1.hs-adpt 11.0.7.hs-adpt and 8.0.252-open

Scala maven and gradle work fine out of box

agilob commented 4 years ago

I'm can reproduce it on another computer with archlinux.

marc0der commented 4 years ago

@agilob I've just tried to replicate this but can't. I'm also on arch linux with oh-my-zsh. I then tried running up a fresh ubuntu docker container, once again it all works fine.

Could you please check that you don't have any special options set in your .zshrc file? Also, can you confirm that you are not using a login shell?

agilob commented 4 years ago

Could you please check that you don't have any special options set in your .zshrc file?

Thanks for info, I investigated it and have to say I had some crap in .profile :(