What should maven M2_Home be? - maven

I installed maven with sudo apt install maven
Then, from this repo ran mvn clean install.
I got the following error
[ERROR] org.eclipse.xtext.maven.plugin.XtextGeneratorIT Time elapsed: 4.246 s <<< FAILURE!
java.lang.AssertionError:
Maven home not found. Tried to call 'mvn'.
Consider to set the envVar 'M2_HOME' or System property 'maven.home'.
Current settings are: maven.home=null M2_HOME=null
What should my M2_HOME be??? I typed mvn --version to get a clue:
$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IL, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-109-generic", arch: "amd64", family: "unix"
But I'm not sure what to do now. Any help is appreciated, thanks!

M2_HOME is a home of Maven. It should be the root directory of your maven installation/binaries. It is used by script mvn (correspondingly mvn.bat on Windows).

Related

Installing Maven on Red Hat Enterprise Linux release 8.3: no Maven version displayed

I installed OpenJDK 11 and Maven 3.8.1 on Red Hat Enterprise Linux release 8.3 as follows:
yum install java-11-openjdk
cd /opt
wget https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
mv apache-maven-3.8.1 /opt/maven
Then I created the maven.sh script to declare JAVA_HOME and M2_HOME environment variables as follows:
vi /etc/profile.d/maven.sh
# added the following content:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
Reloade the shell with source /etc/profile.d/maven.sh.
When checking the installed Maven version, it is not displayed, just the Java's one:
mvn -v
Maven home: /opt/maven
Java version: 11.0.10, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-4.el8_3.x86_64
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "4.18.0-240.15.1.el8_3.x86_64", arch: "amd64", family: "unix"
I hoped to see something like:
Apache Maven 3.8.1 (cecedd343002696d0abb50b32b541b8a6ba2883f)
...
What am I missing? Or everything is correct?
I don't see anything wrong here. I have tried almost the same steps and it worked for me.
Adding those steps below
sudo yum install java-11-openjdk
sudo wget https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
sudo tar xvf apache-maven-3.8.1-bin.tar.gz
sudo ln -s apache-maven-3.8.1 maven
sudo vi /etc/profile.d/maven.sh
added the below
export JAVA_HOME={provide the path, where your jdk is}
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
source /etc/profile.d/maven.sh
mvn -version
screenshot of maven version
Hopefully, this will work for you!

Installing Spark with Maven (MAC OSX)

I am very new to Spark and attempting a first time install. I have downloaded homebrew and installed Maven with it.
I have run the following to ensure the install was done correctly:
Command: maven - v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"
However, when I try to build spark using the following command:
./build/mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package
I get this error:
-bash: ./build/mvn: No such file or directory
UPDATE:
I went on to follow instructions on instaling Spark with Homebrew from here:
• https://medium.com/#josemarcialportilla/installing-scala-and-apache-spark-on-mac-os-837ae57d283f#.ru5hi42v3
This worked fine untill I restarted the terminal. When I execute
spark-shell
I get :
/usr/local/Cellar/apache-spark/2.1.0/libexec/bin/spark-shell: line 57: /usr/local/Cellar/apache-spark/2.0.1/libexec/bin/spark-submit: No such file or directory
Would appreciate any pointers in resolving this.
UPDATE
I have updated my .bash_profile to this.
Still getting the same error. However when I access the files directly by going to the folder via terminal, I can open it.
If the version of spark you installed is not 2.1.0, then you have to modify the line export SPARK_HOME= .... to correspond to version of spark you have.

Build Error Zeppelin 0.6.1

I'm getting a maven build error building Apache Zeppelin branch 0.6.1 on Ubuntu 14.04 LTS.
[ERROR] Failed to execute goal on project zeppelin-spark_2.10: Could not resolve dependencies for project org.apache.zeppelin:zeppelin-spark_2.10:jar:0.6.1-SNAPSHOT: Could not find artifact org.apache.zeppelin:zeppelin-spark-dependencies:jar:0.6.1-SNAPSHOT in apache.snapshots (http://repository.apache.org/snapshots) -> [Help 1]
My build command is:
$ mvn clean package -Pspark-1.6 -Phadoop-2.6 -Pyarn -Ppyspark -Psparkr -DskipTests
I tried compiling with -U and also removing the ~/.m2/repository
Here's the Zeppelin version:
<groupId>org.apache.zeppelin</groupId>
<artifactId>zeppelin</artifactId>
<packaging>pom</packaging>
<version>0.6.1-SNAPSHOT</version>
<name>Zeppelin</name>
<description>Zeppelin project</description>
<url>http://zeppelin.apache.org/</url>
Here's maven and Java versions:
ubuntu#ip-10-0-1-215:~/zeppelin$ mvn -version
Apache Maven 3.3.7-SNAPSHOT (58348a8971e0fb4cf26a281f1cf0f2ce3af9f0c9; 2015-08-17T08:31:09+00:00)
Maven home: /home/ubuntu/apps/maven/apache-maven-3.3.x-SNAPSHOT
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-92-generic", arch: "amd64", family: "unix"
ubuntu#ip-10-0-1-215:~/zeppelin$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
ubuntu#ip-10-0-1-215:~/zeppelin$
ubuntu#ip-10-0-1-215:~/zeppelin$ hadoop version
Hadoop 2.6.4
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r 5082c73637530b0b7e115f9625ed7fac69f937e6
Compiled by jenkins on 2016-02-12T09:45Z
Compiled with protoc 2.5.0
From source with checksum 8dee2286ecdbbbc930a6c87b65cbc010
This command was run using /usr/local/hadoop/share/hadoop/common/hadoop-common-2.6.4.jar
Zeppelin branch 0.5.6 build properly:
git clone https://github.com/apache/zeppelin.git -b branch-0.5.6

How to change maven home directory?

I have maven home directory as below,
[root#localhost configuration-simple]# su -c "vi /etc/profile.d/maven.sh"
[root#localhost configuration-simple]# mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: /home/kartyk/NetBeansProjects/motown.io/motown-develop/apache-maven-3.0.5
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_51/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.8-100.fc20.x86_64", arch: "amd64", family: "unix"
[root#localhost configuration-simple]#
Now I want to change the Maven home directory to some other folder, how could I do this through command prompt?
I assume you are familiar with basics of your OS.
go to Maven download page and get the latest version
extract it in a directory of your choice (/opt or /usr/local or ...)
set and export the environment variable MAVEN_HOME in your .bashrc
extend and export the environment variable PATH by $MAVEN_HOME/bin

Not sure if JAVA_HOME is set

I have installed Maven on Ubuntu 12.04. The following is the output when I do
$ mvn --version
Listening for transport dt_socket at address: 8787
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_38, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/jdk1.6.0_38/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-52-generic", arch: "amd64", family: "unix"
but when I do
$ gedit /etc/environment
the output is
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
also the .bash_rc does not have any entry for JAVA_HOME and there is no .bash_profile file.
My Question
If JAVA_HOME is not set how mvn --version is showing a value of it?
If JAVA_HOME is not set how mvn --version is showing a value of it?
On my system, the mvn program is a shell script, which performs various operations to try to guess a value for JAVA_HOME, if a value is not already set. In particular, it examines the location of the javac program.
However, according to the answer of a related question, what mvn reports as "Java home" is not the value of the JAVA_HOME environment variable: it is the value of the java.home system proeprty
Can be set in /etc/.bash_profile or other system rc files.

Resources