Last active
September 25, 2015 11:24
-
-
Save petems/fa98a6afb067ca9fca0a to your computer and use it in GitHub Desktop.
Java command on OSX with and without installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After installation: | |
==> Downloading http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-macosx- | |
######################################################################## 100.0% | |
==> Running installer for java; your password may be necessary. | |
==> installer: Package name is JDK 8 | |
==> installer: Installing at base path / | |
==> installer: The install was successful. | |
🍺 java installed to '/opt/homebrew-cask/Caskroom/java/1.8.0' (5 files, 208M) | |
vagrant:~ vagrant$ puppet apply foo.pp | |
Notice: Scope(Class[main]): Java version is 1.8.0 | |
Notice: Compiled catalog for vagrant.home in environment production in 0.01 seconds | |
Notice: Finished catalog run in 0.02 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant:~ vagrant$ cat foo.pp | |
notice("Java version is ${::java_version}") | |
vagrant:~ vagrant$ puppet apply foo.pp | |
Could not retrieve fact='java_version', resolution='<anonymous>': undefined method `strip' for nil:NilClass | |
Could not retrieve fact='java_version', resolution='<anonymous>': undefined method `strip' for nil:NilClass | |
Could not retrieve fact='java_version', resolution='<anonymous>': undefined method `strip' for nil:NilClass | |
Warning: Scope(Class[main]): Could not look up qualified variable '::java_version'; | |
Notice: Scope(Class[main]): Java version is | |
Notice: Compiled catalog for vagrant.home in environment production in 0.01 seconds | |
Notice: Finished catalog run in 0.01 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add(:java_version) do | |
confine :operatingsystem => 'Darwin' | |
has_weight 100 | |
setcode do | |
unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1') | |
Facter::Util::Resolution.exec('java -Xmx8m -version 2>&1').lines.first.split(/"/)[1].strip | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant:~ vagrant$ java | |
No Java runtime present, requesting install. | |
vagrant:~ vagrant$ /usr/libexec/java_home --failfast | |
Unable to find any JVMs matching version "(null)". | |
vagrant:~ vagrant$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment