Aemilius
Aemilius

Reputation: 676

Adding a custom path to the Path environmental variable - how does javac look for the path?

Today I have installed the Java Developer Kit. However, when I simply typed javac in my console, it returned an error. Only once I had added the location to my Java bin folder to the Path environmental variable did it finally start to work properly. However, I am not satisfied with this solution and I would like to know exactly why it worked.

How does the process know that once I type javac one of those paths needs to be opened? I have never specified the alias for this path before. Also, does the process iterate through every path present on the environmental variable list until it finds the proper path?

Upvotes: 0

Views: 32

Answers (1)

Sami Sallinen
Sami Sallinen

Reputation: 3496

When you execute a command, the directories in path are searched in the order they appear in the variable until the command you typed is found.

See the first answer here: https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them

Upvotes: 1

Related Questions