Ifyou're using the java cookbook, then the java_home should be made available at node['java']['java_home']. That's what you should use in all your chef recipes, as long as they're run together with the java cookbook that will populate this value.
I'm guessing that I shouldn't have to put these recipe settings in my
nodes/hostname.json file. I tried putting them in the recipe (they will
need to apply to all nodes), but couldn't get that to work.
Because you're including the oracle recipe directly, not using the default
recipe. There are required attributes set in the
set_attributes_from_version recipe, which is included by the default
recipe. You can include this yourself before including java::oracle, but
the recommended method is just to include default (which is why you're
getting that warning when the recipe executes).
I'm the maintainer of the java cookbook, and we pulled out some logic from
the default recipe into set_attributes_from_version so that the cookbook
could more easily be wrapped. For most uses, simply including the default
recipe and setting the install_flavor node attribute (if you wish to
override the default) is sufficient. Perhaps we can make this clearer (such
as raising an exception when expected attributes aren't set).
I'm guessing that I shouldn't have to put these recipe settings in
my nodes/hostname.json file. I tried putting them in the recipe (they will
need to apply to all nodes), but couldn't get that to work.
Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.
Oracle has been known to change the behavior of its download site frequently. It is recommended you store the archives on an artifact server or s3 bucket. You can then override the attributes in a cookbook, role, or environment:
Include the java recipe wherever you would like Java installed, such as a run list (recipe[java]) or a cookbook (include_recipe 'java'). By default, OpenJDK 6 is installed. The install_flavor attribute is used to determine which JDK to install (AdoptOpenJDK, OpenJDK, Oracle, IBM, or Windows), and jdk_version specifies which version to install (currently 6 and 7 are supported for all JDK types, 8 and 10 for Oracle and AdoptOpenJDK ).
Include the default recipe in a run list or recipe to get java. By default the openjdk flavor of Java is installed, but this can be changed by using the install_flavor attribute. By default on Windows platform systems, the install_flavor is windows and on Mac OS X platform systems, the install_flavor is homebrew.
On platforms such as SmartOS that require the acceptance of a license agreement during package installation, set node['java']['accept_license_agreement'] to true in order to indicate that you accept the license.
This recipe installs the oracle flavor of Java. This recipe does not use distribution packages as Oracle changed the licensing terms with JDK 1.6u27 and prohibited the practice for both RHEL and Debian family platforms.
You can not directly download the JDK from Oracle's website without using a special cookie. This cookbook uses that cookie to download the oracle recipe on your behalf, however the java::oracle recipe forces you to set either override the node['java']['oracle']['accept_oracle_download_terms'] to true or set up a private repository accessible by HTTP.
For both RHEL and Debian families, this recipe pulls the binary distribution from the Oracle website, and installs it in the default JAVA_HOME for each distribution. For Debian, this is /usr/lib/jvm/default-java. For RHEL, this is /usr/lib/jvm/java.
After putting the binaries in place, the java::oracle recipe updates /usr/bin/java to point to the installed JDK using the update-alternatives script. This is all handled in the java_oracle_install resource.
While public YUM repos for Oracle Java 7 and prior are available, you need to download the RPMs manually for Java 8 and make your own internal repository. This must be done to use this recipe to install Oracle Java 8 via RPM. You will also likely need to set node['java']['oracle_rpm']['package_name'] to jdk1.8.0_40, replacing 40 with the most current version in your local repo.
Because as of 26 March 2012 you can no longer directly download the JDK msi from Oracle's website without using a special cookie. This recipe requires you to set node['java']['oracle']['accept_oracle_download_terms'] to true or host it internally on your own http repo or s3 bucket.
If you use the windows recipe, you'll need to make sure you've uploaded the aws and windows cookbooks. As of version 1.18.0, this cookbook references them with suggests instead of depends, as they are only used by the windows recipe.
The java::ibm recipe is used to install the IBM version of Java. Note that IBM requires you to create an account and log in to download the binary installer for your platform. You must accept the license agreement with IBM to use their version of Java. In this cookbook, you indicate this by setting node['java']['ibm']['accept_ibm_download_terms'] to true. You must also host the binary on your own HTTP server to have an automated installation. The node['java']['ibm']['url'] attribute must be set to a valid https/http URL; the URL is checked for validity in the recipe.
The java::notify recipe contains a log resource whose :write action is called when a JDK version changes. This gives cookbook authors a way to subscribe to JDK changes and take actions (say restart a java service):
This cookbook contains the java_certificate resource which simplifies adding certificates to a java keystore. It can also populate the keystore with a certificate retrieved from a given SSL end-point. It defaults to the default keystore /jre/lib/security/cacerts for Java 8 or below and /lib/security/cacerts for Java 9+ with the default password if a specific keystore is not provided.
This cookbook contains the java_jce resource, which installs the Java Cryptography Extension (JCE) policy files for a given Java installation. It defaults to installing the JCE files into the Java location defined by cookbook attributes, but it can be customized to install to arbitrary Java locations. Please note that if node['java']['oracle']['jce']['enabled'] is set to true, this custom resource will be run automatically.
It is acceptable to set the node['java']['jdk_version'] to a specific version if required for your software to run, eg software xyz requires Java 8 to run. Refrain from pinning to specific patches of the JDK to allow users to consume security updates.
And Java, as one of the leading programming languages, has many to choose from. That prompted our research into the world's best Java books. We considered the price, length, and expertise of the author. Read on to find Java books that work for your style of learning.
Here, we assembled a list of 11 excellent Java books to advance your learning in Java. Those looking to learn at their own pace may also want to consider on-demand video services. We evaluated Java courses as well. Below, we discuss only Java books as learning resources.
As a reminder, we looked for the depth of the coverage, recent updates, and cost. Our considerations included Java books from many publishers, but you will see several names appear more than once. We respect these publishers for their subject matter expertise and unique insights.
A must-have book for every Java programmer and Java aspirant, Effective Java makes up for an excellent complementary read with other Java books or learning material. The book offers 78 best practices to follow for making the code better. Effective Java divides all the mentioned best practices into 11 distinct sections, such as Concurrency, Generics, and Methods, to make it easier for the reader to grasp it all. The book offers something to Java programmers of any skill level. Effective Java is written by Joshua Bloch, who is also the author of many key Java classes and APIs, including java.lang and Java Collection framework. The context of the latest edition of the book built around Java 7, 8, and 9.
3a8082e126