Which selects the latest installed JDK version of the 1.7 branch. At the end we can simply execute the function using We also update the PATH to point to the bin directory of the newly found JAVA_HOME directory. The -v argument tells java_home to return the path of the JDK with the supplied version, for example 1.7. Then it makes some clever use of /usr/libexec/java_home which is a command that lists installed JDK versions. What the script does is to first remove other JDK versions in the PATH so that they won’t interfere with our new JDK version. RemoveFromPath '/System/Library/Frameworks/amework/Home/bin'Įxport JAVA_HOME=`/usr/libexec/java_home -v PATH=$JAVA_HOME/bin:$PATHĮxport PATH=$(echo $PATH | sed -E -e "s :$1 " -e "s $1:? ") What you do is to edit your ~/.bash_profile and add the following: After a lot of googling I finally found a simple solution that I’d like to share. I especially noticed this after I installed the JDK 8 early access preview which makes some of the tips that you find on various blogs online useless. Java HotSpot(TM) Client VM (build 1.5.Apple decided to remove the Java Preferences application in a software update and afterwards in has been difficult to change the JDK version on Mac OS X. Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Open a new Terminal window (cmd-n) and type: $JAVA_HOME/bin/java -version.Save and exit emacs (ctrl-x, ctrl-s ctrl-x, ctrl-c).Open up Terminal.app (Applications > Utilities > Terminal).Below are instructions on how to accomplish this instead: If you want it to persist, you will have to add the command to your ~/.profile file. Note that this sets JAVA_HOME only for this session. You should now be able to run your application.echo $JAVA_HOME on Terminal to confirm the path.Set JAVA_HOME using this command in Terminal: export JAVA_HOME=/Library/Java/Home.JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java.Check you have the needed version of Java, by typing “java -version”.It should show something like /usr/bin/java. Confirm you have JDK by typing “which java”. Trying to run a Java application on your Mac and need to set your JAVA_HOME? Follow the instructions below to quickly and easily do it:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |