Install java 7 from maven Chef cookbook - java

I want to install the Chef maven cookbook from the community site, and select java version 7. To do so I have added the following attributes in the attributes/default.rb of my recipe.
# Configure java and maven
default['maven']['setup_bin'] = true
node.override[:java][:jdk_version] = '7'
node.override[:java][:openjdk_packages] = [
"openjdk-7-jdk", "openjdk-7-jre-headless"
]
This does not work, as it installs java version 6. I have tried other variants with the same result, such as:
# Configure java and maven
default['maven']['setup_bin'] = true
default['java']['jdk_version'] = '7'
My platform is an Ubuntu precise64.
The output of mvn -v is the following:
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09 17 15:22:22+0000)
Maven home: /usr/local/maven
Java version: 1.6.0_34, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: en_US, platform encoding: ISO-8859-1
OS name: "linux", version: "3.2.0-23-generic", arch: "amd64", family: "unix"
How can I tell the java cookbook to install version 7?
Thanks!
Daniel

Your code is not working because you have not set the node['java']['openjdk_version'] attribute. Here is the relevant code segment:
node['java']['openjdk_packages'].each do |pkg|
package pkg do
version node['java']['openjdk_version'] if node['java']['openjdk_version']
end
end
Another option would be not to set the node['java']['openjdk_packages'] attribute. The set_attributes_from_version recipe contains logic to do this based on the OS.

Related

Idea terminal sees outdated maven version

I upgraded maven version. What I've done:
Downloaded new maven version
Updated PATH environment variable
In idea selected new maven version:
Inside cmd I see correct maven version:
mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files (x86)\apache\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin\..
Java version: 1.8.0_111, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_111\jre
Default locale: en_US, platform encoding: Cp1251
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Also I see correct version in Idea maven plugin:
But when I try to check maven version in the terminakl I see:
How could I acheve that Idea terminal sees new maven version ?
P.S.
shell config:

How to list all incompatible dependancy version with maven?

I'm in to process of upgrading from 1.6 to 1.8.
Because of this, I'm looking for a good way to list all dependencies that aren't Java 1.8 compatible. I've got JAVA_HOME is already set. and I'm using Maven 3.3.9.
I'm looking for something like:
mvn dependancy:compatabilityTest
Environment Info:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: C:\Data\apps\apache-maven-3.3.9\bin\..
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.8.0_112\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"
"Failed to transform class with name" most likely means byte code generation or transformation is being used. There is no way to determine this statically as the class doesn't exist in the form it will be loaded until the program is run.
Java 8 adds some validation to the byte code which wasn't in older versions. This means byte code generated in Java 5.0 which wasn't valid might not have failed but now it does. The solution is to upgrade the version of the byte code generator and most likely the library which uses it.

Why I can not install new maven?

I download a new maven and execute using the full path, but still get the old version, and it doesn't help even I put it on PATH. It's very weird.
I run the maven as version of 3.3.9, but it still use the 3.2.5
-bash-4.1# /usr/hdp/2.3.2.0-2950/apache-maven-3.3.9/bin/mvn --version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/share/apache-maven
Java version: 1.7.0_91, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.7.1.el6.x86_64", arch: "amd64", family: "unix"
M2_HOME is set as the old maven home directory. Seems maven will pick up the MAVEN from this environment variable.

Maven environment mac

I'm trying to build something with maven, but keep getting the following error in intellij
-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
So after searching the internet I found some ideas with the environment variables. But I checked with mvn -version and this is the response I get:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre
Default locale: nl_NL, platform encoding: UTF-8
OS name: "mac os x", version: "10.11", arch: "x86_64", family: "mac"
So I don't really know what I need to do extra to get this started?
If you are using IntelliJ, try to look at this post
You need to set the argument -Dmaven.multiModuleProjectDirectory=$M2_HOME to your JRE

How to build 32 Bits on Mac OS X 10.7.4 64 Bits using Maven

I have just got a Mac BookPro with os OS X Lion which has maven pre installed with the version
#mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 19:31:09+0200)
Maven home: /usr/share/maven
Java version: 1.6.0_31, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: tr_TR, platform encoding: MacTurkish
OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"
When I run a
mvn clean install
maven is somehow failing compiling. One of the fail reason is : java.lang can not found.
When I check java settings I saw that there is both 64 and 32 bit java versions.
thanks.
In the Java properties :
There are two Java instances
Java SE Apple Inc. 64 Bits 1.6.0_31-b04-415
Java SE Apple Inc. 64 Bits 1.6.0_31-b04-415
First try to write HelloWord.java and compile it using command line javac HelloWord.java.
If it works move towards maven. Check environment variable JAVA_HOME that is used by maven to find java. I believe it points to "wrong" java version. Fix this and try again. I hope this will work.

Categories

Resources