0
# java
if [ -d "$HOME/Downloads/jdk1.8.0_152" ] ; then
    JAVA_HOME="$HOME/Downloads/jdk1.8.0_152"
fi
if [ -d "$HOME/Downloads/jdk1.8.0_152/bin" ] ; then
    PATH="$HOME/Downloads/jdk1.8.0_152/bin:$PATH"
fi

I already have Java installed and if I type which java it shows:

/home/aero/Downloads/jdk1.8.0_152/bin/java

and if I type java -version it shows:

java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

but if I want to install elasticsearch by:

sudo dpkg -i elasticsearch-6.6.1.deb

it shows:

(Reading database ... 285478 files and directories currently installed.)
Preparing to unpack elasticsearch-6.6.1.deb ...
could not find java; set JAVA_HOME or ensure java is in PATH
dpkg: error processing archive elasticsearch-6.6.1.deb (--install):
 new elasticsearch package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 elasticsearch-6.6.1.deb

1 Answer 1

1

Check if you have Java available when you execute through sudo.

sudo which java

If the above one does not show Java, try the following command:

sudo -E which java

The -E switch is to preserve the environment variables while executing sudo.

If the above one works, see if sudo -E dpkg -i <dpkg_file> works.

If the above steps does not help, I would recommend you to move the Java install folder outside the user home folder to some common location like /opt, see if the binaries have permissions, redefine the JAVA_HOME variable and redo the above steps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.