Dmaven.multiModuleProjectDirectory system propery is not set - java

1) Downloaded maven.
2) tar xzvf apache-maven-3.3.9-bin.tar.gz
3) I tried to install maven 3.3.9 on my Mac and when I check the "mvn --version" it says
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match
4) My bash_profile looks like
export M2_HOME=/Users/vijay/Documents/Softwares/apache-maven-3.3.9
export PATH=$PATH:$M2_HOME/bin
MAVEN_OPTS="-Xmx4096m"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
Can anyone suggest to resolve it and get the maven installed corectly on my Mac

set environment variables like :
export M2_HOME=/Users/vijay/Documents/Softwares/apache-maven-3.3.9
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xmx4096m
export PATH=$M2:$PATH

Related

Adding maven to PATH on macOS Big Sur

How to add Apache Maven to PATH on macOS Big Sur permanently ? I have downloaded and unzipped maven.
If you have downloaded maven from apache, and extracted the binary.zip, first you need to check your terminal type. To view it open your terminal and type,echo $SHELL
Then you will get your terminal type(zsh or bash).
If its bash open the .bash_profile file by,
either open ~/.bash_profile or vi ~/.bash_profile.
Then add the apache maven path to it by first declaring the MAVEN_HOME and M2_HOME.
export MAVEN_HOME = '/{your-maven-location}/apache-maven-3.8.2/'
export M2_HOME = '/{your-maven-location}/apache-maven-3.8.2/'
Then add those to the PATH variable by,
export PATH="$MAVEN_HOME/bin:$PATH"
export PATH="$M2_HOME/bin:$PATH"
After adding these lines save the .bash_profile.
Then in terminal type source ~/.bash_profile to source the file.
Now, if you type echo $PATH you can see the maven is added to your path.
And do the same thing for .zshrc file by opening it using open ~/.zshrc or vi ~/.zshrc.
You can either change .bash_profile or .zshrc file depending on the shell you have. But,I would recommend you to add the path variable to both files.
If you are having any sourcing issues, give file changing privileges by, sudo chown {your-username} ~/.bash_profile or sudo chown {your-username} ~/.zshrc.
You can find your username by ls -al /Users

How to set JAVA_HOME variable in hadoop in ubuntu 16.04

On hadoop installation in ubuntu-16.04, I got
hdadmin#ubuntu:~/hadoop-2.5.0-cdh5.3.2$ bin/hdfs namenode -format
bin/hdfs: line 301: /usr/lib/jvm/java-8-oracle//bin/java: No such file or directory
Following is the value of JAVA_HOME in hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
And following lines I added in .bashrc file
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
export HADOOP_PREFIX="/home/hdadmin/hadoop-2.5.0-cdh5.3.2"
export PATH=$PATH:$HADOOP_PREFIX/bin
export PATH=$PATH:$HADOOP_PREFIX/sbin
export HADOOP_MAPRED_HOME=${HADOOP_PREFIX}
export HADOOP_COMMON_HOME=${HADOOP_PREFIX}
export HADOOP_HDFS_HOME=${HADOOP_PREFIX}
export YARN_HOME=${HADOOP_PREFIX}
I installed java using following commands
sudo apt install default-jre
sudo apt install default-jdk
And why it is saying java-8-oracle folder while my folder name is something else
Try the following lines to set java environment path
Edit the system Path file /etc/profile
sudo gedit /etc/profile
Add at the end
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

'$HADOOP_HOME/bin/hadoop version' works fine but 'hadoop version' doesnt work

I have installed hadoop 3.1.0 version and set env variables. When i run $HADOOP_HOME/bin/hadoop version, it is shown that i installed but running hadoop version is not able to find the hadoop command (within hadoop user)
My environment variables are like below:
#HADOOP VARIABLES START
export HADOOP_HOME=$HOME/usr/local/hadoop
export HADOOP_CONF_DIR=$HOME/usr/local/hadoop/etc/hadoop
export HADOOP_INSTALL=$HOME/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export PATH=$PATH:$HOME/usr/local/hadoop
#HADOOP VARIABLES END
echo $HADOOP_HOME
/usr/local/hadoop
echo $HOME
/home/hduser
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$HADOOP_HOME/bin/hadoop version
Hadoop 3.1.0
Source code repository https://github.com/apache/hadoop -r 16b70619a24cdcf5d3b0fcf4b58ca77238ccbe6d
Compiled by centos on 2018-03-30T00:00Z
Compiled with protoc 2.5.0
From source with checksum 14182d20c972b3e2105580a1ad6990
This command was run using /usr/local/hadoop/share/hadoop/common/hadoop-common-3.1.0.jar
Seems like my global path is not working properly. I may miss something, i was trying to figure it out for hours, but nothing works. Thanks a lot
From your echo $PATH result, looks like hadoop path is not added to your PATH.
Where did you write your export statements? Try adding them to ~/.bashrc and starting a new terminal.

How to install Maven on OSX 10.10 (Yosemite)?

I am trying to install Maven on my Mac, but I can not get the JAVA_HOME variable right. The path that the maven website gives is,
usr/java/jdk1.7.0_51
however the java folder does not exist in /usr/ for me. I installed the JRE and JDK, nothing changed. How can I fix this?
Using brew - brew install maven - that's it.
Installing Maven (for me) usually involves these steps (apart from having a working java installed):
Download Maven from http://maven.apache.org/download.cgi
Unpack to /path/to/maven
Set the following in .bashrc
export M2_HOME=/path/to/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
Reload bash, and now "mvn --version" should be fine. Make sure to not have any reference to JAVA_HOME in your .bashrc (or .bash_aliases) if you havent already set it to somewhere you placed your jdk.
In my case, none of the exported variables saved after bash quit. Also, export M2=$M2_HOME/bin; export PATH=$M2:$PATH into bash didn't help, either. So, I had to write absolute paths into bash profile. Here are my steps:
1) open bash
2) next two steps are required to correctly create paths in your system. Type in (line by line)
JAVA_HOME=/usr/libexec/java_home
export M2_HOME=/path/to/your/apache-maven-3.x.x
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
3) than echo all four variables
echo $JAVA_HOME
echo $M2_HOME
echo $M2
echo $PATH
4) open second window of bash for your convenience.
5) choose root folder (type cd without anything and press enter)
cd
6) if you don’t have file called «.bash_profile» than just create it
touch .bash_profile
7) open edit your «.bash_profile»
nano .bash_profile
5) copy results of echo commands to your «.bash_profile». it should look something like.
JAVA_HOME=/usr/libexec/java_home
M2_HOME=/path/to/your/apache-maven-3.x.x
M2=/path/to/your/apache-maven-3.x.x/bin
PATH=/path/to/your/apache-maven-3.x.x/bin:/path/to/maven/bin:/$….bla-bla-bla…
6) after edit save by pressing ctrl+s and close by ctrl+x
For Macports : sudo port install maven3
Change maven3 to maven1 or maven2 for corresponding version number.
On Yosemite, I've not had JAVA_HOME defined and I have version '1.7.0_65'. I also have maven installed and use it nearly every day. Installation of maven is performed by the following steps:
curl http://download.nextag.com/apache/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz | tar pzxvf -
set the MAVEN_HOME environment variable to:
pwd/apache-maven-3.2.3
add MAVEN_HOME to your path.
Now you should be golden. Leave a comment if you aren't sorted.
Sorry this is late.
I installed JDK and Maven following instructions from each of those sites, then I had to edit my .profile file to get the PATH variables set.
$ sudo vim .profile
Then I added the following to my .profile (i for insert mode)
# JDK configuration
#
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
#
# Maven configuration
#
MAVEN_3_3_3=/opt/maven/apache-maven-3.3.3
export MAVEN_3_3_3
M2_HOME=$MAVEN_3_3_3
export M2_HOME
PATH=$PATH:$M2_HOME/bin
export PATH
Next you write and quit vim (:wq), quit and reopen terminal and type mvn --version to test your install.
Your output should look like this:
$ mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T06:57:37-05:00)
Maven home: /opt/maven/apache-maven-3.3.3
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
Note: you may need to adjust the paths to your jdk and maven installations.

set MAVEN_HOME in eclipse

I have this line of code in a project in eclipse & it's giving me error.
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File(System.getenv("MAVEN_HOME"))); //giving error
So I ran and its giving blank line as output
echo $MAVEN_HOME
However, I am able to run other maven projects through command prompt and through eclipse.
I have following question..
Q 1. what is the difference between the following two commands
whereis maven
maven: /etc/maven /usr/share/maven
& when I run
whereis mvn
mvn: /usr/bin/mvn /usr/bin/X11/mvn /usr/share/man/man1/mvn.1.gz
Q 2. what do I need to put in .bashrc... please tell me exactly...
this is my current content of .bashrc file
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
export JAVA_HOME
export PATH
EDIT
mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Thanks :)
Just to use in eclipse you can add this in Window -> Preferences -> Java -> Build Path -> Classpath Variables.
Just add new variable with name MAVEN_HOME.
But for executions you need to set in in Run/Debug configuration - probably that's what you need.
whereis maven
is about directory, and
whereis mvn
is about executable file.
For .bashrc:
MAVEN_HOME=/usr/share/maven
export MAVEN_HOME
Don't set the MAVEN_HOME in bashrc file but set it in the Environment tab of the launcher configuration of Eclipse.
The .bashrc file is for the bash environment
Basically invoker.setMavenHome(MAVEN_HOME); this needs the home directory where you have installed maven. If you need to find where is the home directory of maven. You can you use following approaches as you tried.
whereis maven
This will be showing where is the location which maven has been installed into your computer.
maven: /etc/maven /usr/share/maven

Categories