0

Linux Mint 19.3.

Content of /home/alexei/.bash_profile

export JAVA_HOME=/usr/java/jre1.8.0_251

here folder with jre

enter image description here

But when I run java from bin folder I get error:

java -version

Command 'java' not found, but can be installed with:

sudo apt install default-jre            
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless 

How I can fix this?

Alexei
  • 14,350
  • 37
  • 121
  • 240

1 Answers1

1

This is normal behavior. cd'ing to a directory does not make the programs available like it does in Windows cmd.exe.

To run a file in the current directory, you can instead use ./java -version

(Related: Why do you need ./ (dot-slash) before executable or script name to run it in bash?).

To be able to run java from any directory, first see if your distro has a mechanism in place (e.g. update-alternatives --config java). If not, you can always manually add the directory to your PATH.

that other guy
  • 116,971
  • 11
  • 170
  • 194