2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Change Java Versions

Last updated at Posted at 2015-03-21

show existing java versions.

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.0_40, x86_64:	"Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
    1.7.0_75, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

change java versions

# show current version
$ java -version
ava version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

# To change java version 1.7 to 1.8
# set your JAVA_HOME in your shell startup . file
# mine is ~/.zshrc
$ vi ~/.zshrc
	# Change the following codes to your ~/.zshrc
	
	# inactive your java version 1.7
	# export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
	
	# active your java version 1.8
	export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
	
# run your ~/.zshrc file
$ source ~/.zshrc

# check current java version
$ java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?