Naturally if you don’t want to use the latest and greatest you could specify that you want to use the 64-bit JDK 1.7 like this: export JAVA_HOME=`/usr/libexec/java_home -d 64 -v "1.7*"` You can also put it in /etc/profile if you want it to be available to all users and not just yourself. This line would typically go in ~/.bashrc if you use bash or ~/.zshrc if you use zsh. export JAVA_HOME=`/usr/libexec/java_home` This helps us because we can simply do something like this in our shell configuration files to make JAVA_HOME always point to the latest JDK by default. The tool can do some other stuff too and the manual page is clear and concise. If that’s a bit wordy for you you can do the same thing by specifying the data model (bits) too: ➜ ~ /usr/libexec/java_home -d 32 ➜ ~ /usr/libexec/java_home -d 64 You can also do some cool stuff like filter by cpu architecture: ➜ ~ /usr/libexec/java_home -a i386 ➜ ~ /usr/libexec/java_home -a x86_64 I have omitted the JDK paths for brevity. ![]() You can also ask it to list all of your JDKs too by using the -V argument. The simplest usage of the tool will return the default JDK, which in my case is update 131 of JDK 1.8. ![]() OS X has had a very useful utility, since 2003, that allows you to easily generate a path to a JDK.
0 Comments
Leave a Reply. |