jdk and jRE installed but still get Unable to locate a Java Runtime that supports apt

Viewed 83

i'm trying to install apach lib on my mac os like this

sudo apt install php libapache2-mod-php

i have this error The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. Please visit http://www.java.com for information on installing Java.

i already installed JDK and JRE

1 Answers

I don't actually use MacOS but, try your environmental variables.

If you don't get a version back when using the command: java -version (without the quotes), the path to java probably isn't set right.

We can further check that this is the case by using the command: printenv or env to get a print out of all the variables that are pathed on your machine.

You can check to make sure your java is installed in the default location by using /usr/libexec/java_home

Then you can add to the environmental variables list by:

  1. Find the path to .bash_profile by using:

~/.bash-profile

  1. Open the .bash_profile file with a text editor of your choice.

  2. Scroll down to the end of the .bash_profile file.

  3. Use the export command to add new environment variables:

export [variable_name]=[variable_value]

The command should look something like this

export JAVA_HOME=$(/usr/libexec/java_home)

This is just a guess as I again don't use Mac or have access to one

  1. Save any changes you made to the .bash_profile file.

  2. Execute the new .bash_profile by either restarting the terminal window or using:

source ~/.bash-profile

Related