It is to specify the directory to be searched automatically when the program is executed.
For example, when deploying a JDK
For windows ** C: \ Java \ jdk1.8.0 \ Home ** \ bin (Omitted below) On Mac ** ~ / Library / Java / JavaVirtualachine / jdk1.8.0 / Home ** / bin (abbreviated below)
Even with the same JDK, the hierarchy until reaching the directory may be different. Therefore, in order to absorb this difference, the above bold part is defined as ** $ JAVA_HOME $ ** on the execution machine (compiler?) So that it can be used in any environment.
Of course, $ JAVA_HOME $ is not defined on a computer that is not doing anything, so you have to set it for each environment. This is expressed as ** in the PATH **. There are various ways to call PATH depending on the middleware, such as PATH for the PC (OS unit), JAVA_HOME for Java, CATALINA_HOME for tomcat, and HTTPD_HOME for apache. Some middleware will automatically put it in your PATH during installation, but Java won't do it for you, so you'll have to do it yourself. Alternatively, you can place your own shortcut by putting it in a specific folder in the PATH. → One of the strongest launchers that Windows programmers should definitely prepare
Work using the terminal.
On Mac, a file called **. Bash_profile ** describes the environment variables that Windows calls. Open this. It will probably open in a text editor.
$ open ~/.bash_profile
If the file does not exist on a new Mac, create it.
$ touch .bash_profile
There is a file called .bashrc that is a perfect match for .bash_profile. The difference between the two
.bash_profile → Automatically loaded at login .bashrc → Loaded when bash (terminal) starts
is. .bash_profile seems to have a higher priority. Basically, let's edit .bash_profile.
Add with the following grammar.
$export variable name=directory
If you want to add it to a variable that already exists, add it with the following syntax.
$ export $Original variable name:Variable name=Directory path
You can increase the priority by adding the original variable name to the end.
$export variable name:$Original variable name=Directory path
If you want to add Java execution environment to PATH and JAVA_HOME newly, add it like this.
export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
After adding, please overwrite and save.
Apply .bash_profile.
$ source ~/.bash_profile
I passed by this. Restart the terminal and check if it really works.
$ echo $PATH
$ echo $JAVA_HOME
If the added directory is displayed, it is successful.
How to pass through PATH Open ~ / .bash_profile allows you to edit .bash_profile! Mac OS X is too convenient PATH on Mac Understanding the setting of environment variables to be in the PATH (Mac OS X) Creating and editing .bash_profile in PATH on Mac
Recommended Posts