Elasticsearch-keystore list command could not find java

Hi Team

we are migrating ES 6.8.5 Java environment from Java8 to Java11. we are using oraclejdk11 as our Java vendor. we set Java_home in bin/elasticsearch file like below

usr/java/jdk11

In ansbile below task is failed to execute

  • name: List what we have in keystore
    command: >
    {{ elastic_dir }}/bin/elasticsearch-keystore list

we get below error

"stderr": "which: no java in (/sbin:/bin:/usr/sbin:/usr/bin)\ncould not find java; set JAVA_HOME",

Update:

if I run the elasticsearch-keystore list command through putty it executes fine.