How can you change the default version of Java on a mac?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Use jenv is an easy way.
1.Install jenv
2.Config jenv
3.Symlink the jdk path
4.You are all set
switch command:
set default:
From the Apple's official java_home(1) man page:
Adding to the above answers, I put the following lines in my
.bash_profile
which makes it really convenient to switch (including @elektromin's comment for java 9):After inserting, execute
$ source .bash_profile
I can switch to Java 8 by typing the following:
Based on @markhellewell answer I created a couple of alias functions that will do it for you. Just add these to your shell startup file
https://gist.github.com/Noyabronok/0a90e1f3c52d1aaa941013d3caa8d0e4
put this in your ~/.profile and use it in your terminal like so
setjdk 1.8
,setjdk 1.7
,setjdk 9
etc etc...If you don't have
removeFromPath
then it is:function removeFromPath() { export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;") }
If you have multiple versions and you want to run something by using a specific version, use this example: