Skip to content

Instantly share code, notes, and snippets.

@Atalanta
Created November 14, 2011 02:34
Show Gist options
  • Save Atalanta/1363108 to your computer and use it in GitHub Desktop.
Save Atalanta/1363108 to your computer and use it in GitHub Desktop.
Finding JAVA_HOME on OSX
#!/usr/bin/env ruby
java_dir = %x[ls -l $(which java)].split.last
java_home_command = java_dir.gsub('java', 'java_home')
print "JAVA_HOME is: "
java_home = system(java_home_command)
@fnichol
Copy link

fnichol commented Nov 22, 2011

There is also a command (/usr/libexec/java_home) from Lion down to Leopard (possibly lower) that can tell you what JAVA_HOME has been set to. https://github.com/fnichol/bashrc/blob/master/bashrc#L156-158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment