Mac OS (version 10.13.4)

What is JAVA_HOME?

In Java, that information is stored in folders for each version. It's annoying to point to the hierarchy / Library / Java / JavaVirtualachine / jdk {version} / up to that point, so I put it in a variable called JAVA_HOME and handle it easily.

How to set

1, registration

export JAVA_HOME=`directory`

It seems that you can type the command of. The directory is


It can be displayed with a command. This command is


The above hierarchy / Library / Java / JavaVirtualachine / jdk {version} / is displayed as a shortened system of.

2, confirmation


It's okay if you can call it with this command.

Java version switching

When you want to use Java 9

export JAVA_HOME=`/usr/libexec/java_home -v 9`

When you want to use Java 8

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Do you switch in this way?

Articles that I used as a reference

Thank you very much JAVA_HOME settings on Mac Learn the meaning of "passing the PATH" by building a Java development environment on Mac

Recommended Posts

About =
About method.invoke
About Kotlin
About attr_accessor
About Hinemos
About inheritance
About params
About Docker
About Rails 6
About form_for
About Spring ③
About enum
About polymorphism
About hashes
About JitPack
About this ()
About devise
About encapsulation
About Docker
About active_hash
About static
About exceptions
About scope
[Maven] About Maven
About exception handling
Review about bundler
About Java interface
[Java] About Java 12 features
About Rails routing
About cyclomatic complexity
About AsyncTask Generics
About Ruby symbols
About array multiplication
[Java] About arrays
About HotSpot VM
About ruby ​​form
[Swift] About generics
About Active Storage
About class inheritance.
About Spring AOP
About Ruby Hashes
About singular methods
About getter setter
JAVA_HOME and Path
About build tools
About MacinCloud introduction
[Note] About nil
Chew about API
[About double hash]
About installing Cocoapods
Something about java
Where about java
About HttpServlet () methods
About Java features
About ActiveRecord :: PendingMigrationError
About SIGNING_REGION: NoSuchFieldError
About the method
About standard classes
About spring AOP
About Ruby arrays