Filter JVMs matching architecture (i386, x86_64, etc). Filter Java versions in the "JVMVersion" form 1.X(+ or *). Returns the path to a Java home directory from the current user's settings. If you prefer XML output, java_home also has a -X option to output in XML. ![]() You might be able to do if-else and check for multiple different versions of java as well. ![]() # Do this if you want to export JAVA_HOMEĮcho "Did not find any installed JDK for version $REQUESTED_JAVA_VERSION" If POSSIBLE_JAVA_HOME="$(/usr/libexec/java_home -v $REQUESTED_JAVA_VERSION 2>/dev/null)" then You could take advantage of the above commands in your script like this: REQUESTED_JAVA_VERSION="1.7" Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home ![]() ![]() Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home To request the JAVA_HOME path of a specific JDK version, you can do: $ /usr/libexec/java_home -v 1.7 To list all versions of installed JDK: $ /usr/libexec/java_home -Vġ.8.0_51, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Homeġ.7.0_79, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home You can leverage the java_home helper binary on OS X for what you're looking for.
0 Comments
Leave a Reply. |