First, write at the beginning
Playing JDK on Mac is slightly different from windows. Mac is a UNIX-style system, so configuration files are hierarchical.
The following will build the blog from the lookup of the environment variable, the configuration of the environment variable (grading), and how to switch the currently used JDK three types of operations
Second, the actual operating record
(1) Java_home Search
The main method is the client command Echo $JAVA _home
Occasionally the command which Java(which command is used to find the source of the command in Linux $path)
Of course, you can also use /usr/libexec/java_home-v to view the installation and version details of the JDK, similar to or equivalent to java-version
(2) environment variable configuration
There are four ways to configure environment variables
But the commands that are executed are
Export Java_home=xxxxxx
Export class_path= "$JAVA _home/lib"
Export Path= ". $PATH: $JAVA _home/bin"
(a) configured as a system level, available to all users
Vi/etc/profile
Add the above three sentences to the document export
and use source/etc/profile to make it effective immediately.
(b) configured as a system level, valid for the current user
VI ~/.bash_profile
Add the above three sentences to the document export
Then use the source ~/.bash_profile to make it effective immediately.
(c) Console processing, immediate effect, closing session immediately invalid
Perform the above three export directly on the console
Note:
The export settings performed by the console are only valid for the current bash login session. This is present in memory and does not write files.
Extended Learning
mac modifies Java version
sudo vim/etc/.bashrc
Inside Plus
Export Java_home=java Path
Export path= $JAVA _home/bin: $PATH
Save Close
sudo source/etc/bashrc
Refer to: 78546354
Reference Source:
Java_home Find
Https://www.cnblogs.com/albert1017/p/4739594.html
Configure Java_home
http://blog.csdn.net/caiwenfeng_for_23/article/details/44243083
Http://blog.sina.com.cn/s/blog_7d1c5c8601015ppr.html
Https://www.cnblogs.com/SnowingYXY/p/6723019.html
Tomcat "Djava endorsed dirs=" error message appears
Http://www.blogjava.net/shangaijun/archive/2007/07/31/133485.html
Jekins Configuring the JDK
https://www.jianshu.com/p/d8d1d72d0248
Java environment variable configuration on Mac