Learn the meaning of "passing the PATH" by building a Java development environment on Mac

To pass through PATH

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

flow

  1. Open .bash_profile
  2. [Add PATH and JAVA_HOME](http://qiita.com/s_hino/items/a185deb4f9fc31c0f5e2#2-path%E3%81%A8java_home%E3%82%92%E8%BF%BD%E8%A8% 98% E3% 81% 99% E3% 82% 8B)
  3. [Application and Confirmation](http://qiita.com/s_hino/items/a185deb4f9fc31c0f5e2#3-%E7%A2%BA%E5%AE%9A%E3%81%A8%E7%A2%BA%E8 % AA% 8D)

Work using the terminal.

1. Open .bash_profile

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.

2. Add PATH and JAVA_HOME

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.

3. Application and confirmation

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.

reference

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

Learn the meaning of "passing the PATH" by building a Java development environment on Mac
Build a Java development environment on Mac
Create a Java development environment using jenv on Mac
[For beginners] Until building a Web application development environment using Java on Mac OS
Install Java development environment on Mac
Java development environment construction memo on Mac
[Ruby] Building a Ruby development environment on Ubuntu
Docker the development environment of Ruby on Rails project
Java development environment (Mac, Eclipse)
Docker × Java Building a development environment that is too simple
A memorandum of the environment variable "JAVA_HOME" path setting procedure
Note on the path of request.getRequestDispatcher
I tried to create a Spring MVC development environment on Mac
About the current development environment (Java 8)
Notes on building Kotlin development environment and migrating from Java to Kotlin
Build Java development environment (for Mac)
[ev3 × Java] leJOS development environment construction (Eclipse on Mac OSX / bluetooth)
Java development environment (Mac, VS Code)
[java tool] A tool that deletes files under the specified path by extension
A record of setting up a Java development environment with Visual Studio Code
Creating a java web application development environment with docker for mac part1
How to solve the local environment construction of Ruby on Rails (MAC)!
How to get the absolute path of a directory running in Java
Create a java web application development environment with docker for mac part2
[Processing x Java] Construction of development environment
Building a Lambda development environment in Eclipse
Building a Kotlin development environment using SDKMAN
Let's create a Java development environment (updating)
What is Java and Development Environment (MAC)
Build Java 8 development environment on AWS Cloud9
Looking back on the basics of Java
Build a JMeter environment on your Mac
Summary of Java environment settings for myself [mac]
Measure the size of a folder in Java
[Java] Build Java development environment on Ubuntu & check execution
Improve the performance of your Docker development environment
Switch between multiple versions of Java on Mac
A reminder of Docker and development environment construction
Ruby on Rails development environment construction on M1 Mac
I touched on the new features of Java 15
Build a development environment for Docker, java, vscode
Points stuck in building VSCode & Java development environment
Build a Java runtime environment on Sakura VPS
I tried running Java on a Mac terminal
[Java] The word passing by reference is bad!
Build a Java development environment with VS Code
[Java] Integer information of characters in a text file acquired by the read () method
A memo when building a Rails 5.2 development environment using Docker Desktop + WSL2 on Windows 10 Home
Simple statistical analysis of monetary value from the list searched by Mercari Java development
Java development environment
A review of the code used by rails beginners
Build a Ruby on Rails development environment on AWS Cloud9
Java development environment construction on Mac-JDK Install (2020 preservation version)
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Experience of passing Java Silver as a new graduate
As of April 2018 How to get Java 8 on Mac
[Java] When writing the source ... A memorandum of understanding ①
Create a Java, JavaScript team development environment (problem raising)
[Environment construction] Build a Java development environment with VS Code!
Try to build a Java development environment using Docker
A survey of the Kubernetes native Java framework Quarkus