I'm wondering if
$PATH cascades entries. You'll all need to take a leap of faith with me here, but here it goes.
Let's say we have a Java executable at
/usr/bin/java but this version is very old and outdated. Unfortunately, we don't have
su access so we can't just replace it. We can, however, download the current version of the JRE/JDK locally and point to the updated version. My question is, how does bash handle the case where we have two or more executables with the same name but in two or more different locations? Does bash somehow choose which one to execute when we type
java into the console? Assuming
/usr/bin has many other executables that we need, how would the
$PATH look for something like this to work correctly?
Ideally, when we type
java -version we should see:
java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) Client VM(build 24.45-b08, mixed mode, sharing)
I'm sure this question has been asked before and has some type of jargon associated with it. I've poked around SE, SO, and some forums but didn't find anything conclusive.