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
Related
I have an Amazon EC2 t3.medium instance on Linux.
I am trying to run Apache ni-fi on this instance and I need java.
When I check the JAVA_HOME default:
$ echo$JAVA_HOME
-bash: echo/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261-2.6.22.2.amzn2.0.2.x86_64: No such file or directory
Then, I downloaded java 1.8 by the following comamnds on terminal:
$ sudo yum install java-1.8.0-openjdk.x86_64
$ sudo update-alternatives --config java
(I selected 2 for java 1.8)
To find the location of my java file, I run them:
$ file $(which java)
/usr/bin/java: symbolic link to `/etc/alternatives/java'
$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java'
$ file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.2.0, BuildID[sha1]=1b1c0fd721197a04f9bfc9b0891f1bd83a5f49d5, not stripped
I guess it is working properly. Then, I change JAVA_HOME from 1.7 to 1.8 by writing these commands on terminal for both ec2-user and root:
[root#ip-178-32-11-247 ~]# export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64"
[root#ip-178-32-11-247 ~]# PATH=$JAVA_HOME/bin:$PATH
In advance, I have setup nifi on root. And in nifi-1.16.0 directory, I am trying to run this command:
[root#ip-178-32-11-247 nifi-1.16.0]# bin/nifi.sh start
The Error message is:
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64
NiFi home: /root/nifi-1.16.0
Bootstrap Config File: /root/nifi-1.16.0/conf/bootstrap.conf
bin/nifi.sh: line 401: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/bin/java: No such file or directory
I thought that java is working but JAVA_HOME couldn't setup properly but I couldn't solve that. What should I do at that point to solve the problem and start nifi?
I will be appreciated very much if you can help, I coludn't start my term project because of this error :(
The correct path for JAVA_HOME should be /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java"
But probably you don't need to export JAVA_HOME anyway. You should have a link in /usr/bin/. You can check this by doing the following:
[ssm-user#ip-172-31-85-243 bin]$ which java
/usr/bin/java
By default Apache Nifi is using the executable /usr/bin/java, so you don't need to export JAVA_HOME.
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
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.
I am trying to get apache ant 1.8 to work under CentOS. First, I had this error.
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
Then I set the following variables according to this link:
Ant: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
It's not CentOS, but I did verify the paths exist except JAVA_HOME, so I set it according to this site:
https://serverfault.com/questions/50883/what-is-the-value-of-java-home-for-centos
Now I am getting the same error I did the first time. It does not matter which ant rule I use, I still get the same error.
[alpha:~]
[bullshark]% export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/
[alpha:~]
[bullshark]% export ANT_HOME=/usr/share/ant/
[alpha:~]
[bullshark]% export PATH=$PATH:$ANT_HOME/bin
[alpha:~]
[bullshark]% cd JRobo
[alpha:JRobo] on master
[bullshark]% ant clean-and-fat-jar
Picked up _JAVA_OPTIONS: -Xmx64m
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
[alpha:JRobo] on master
[bullshark]% cat /etc/redhat-release
CentOS release 6.3 (Final)
[alpha:JRobo] on master
[bullshark]%
You can clone him on CentOS if you want to try:
https://github.com/BullShark/JRobo
For Apache Ant 1.8 on CentOS:
http://www.jpackage.org/browser/rpm.php?jppversion=6.0&id=11867
For a package or manually:
https://ant.apache.org/bindownload.cgi?Preferred=ftp://apache.mirrors.pair.com/
Here are the steps required to get ant 1.8 installed on CentOS:
Download http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.gz
Copy the tarball to your CentOS home folder (if it's not already there)
tar xvzf apache-ant-1.8.4-bin.tar.gz
sudo mv apache-ant-1.8.4 /opt/ant
Set ANT_HOME=/opt/ant
Add ‘export ANT_HOME=/opt/ant’ to /etc/profile
To verify that it worked, run:
ant -version
I'm trying to switch maven from 2 to 3 (on Linux) using:
sudo update-alternatives --set mvn /path/to/maven3/bin/mvn
Anyway mvn -v still gives version 2, so I always have to execute /path/to/maven3/bin/mvn to use maven. How can I rebind the mvn command to the appropriate maven path?
Run:
sudo update-alternatives --config mvn
Then choose which version you want use.
Also check than which mvn is symbolic link to /etc/alternatives/mvn
which mvn
And then recreate symbolic link to point on new Maven version. And verify than environment variable MAVEN_HOME points to the right directory.
Set system property M2_HOME to path to the maven home.