Apache Maven installation in window 8 - java

Actually I tried to install Apache Maven to my system.
I followed these steps:
Downloaded apache-maven-3.3.3 in my Window 8 machine and copied to Program Files.
Then added maven path C:\Program Files\apache-maven-3.3.3 as M2_HOME in system variable and added C:\Program Files\Java\jdk1.8.0_31 as JAVA_HOME.
Then added ;%M2_HOME%\bin to default Path.
Then tried to run as mvn -version in CMD.
But I got the result like:
mvn is not recognized as an internal or external command...

I remember I had similar issue some time ago on Windows 7. On Windows 8 it may behave similarly. Your solution should work correctly, but for some reason it's not working.
Add path to bin/ directory inside your Maven directory to the Path system variable after semicolon. In your case it will be:
C:\Program Files\apache-maven-3.3.3\bin
Save Path variable, close terminal, run it again and type: mvn -version.

Related

Setting JAVA_HOME variable

I try to set JAVA_HOME variable on an ubuntu server. I get the Java path with this command
which java
/usr/bin/java
I set the result in /etc/environment
JAVA_HOME="/usr/bin/java"
When I try to run a mvn command I get this error
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/bin/java/bin/java
You should not set JAVA_HOME to /usr/bin/java, because that's just a symbolic link to the java executable, which points to where the real executable is.
JAVA_HOME should point to the Java installation directory, and not to the java executable (or a link to the executable).
Find out where your Java installation directory is and then set JAVA_HOME to that directory (and not to the java executable). If you installed Java using Ubuntu's package management system, then the Java home directory is probably one of the subdirectories in /usr/lib/jvm.
Per the Oracle site:
export JAVA_HOME=jdk-install-location
export PATH=$JAVA_HOME/bin:$PATH
You can add these lines into your ~/.bash_profile (or ~/.bashrc), and then refresh using source ~/.bash_profile

Can't set up Maven on Mac OSX

I am new to Mac OSX and I'm running Yosemite. I am trying to set up Maven using this official guide in order to set up a Google Cloud Messaging Backend. Here's what I did:
1) Downloaded Maven zip (version: apache-maven-3.3.9) and Unzipped it
2) As the guide says, I need to add the bin directory to my PATH variable. So I did the following in my terminal
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
The terminal didn't return any response. However when I checked to see if Maven got installed using:
mvn -version
I get a message saying:
-bash: mvn: command not found
What am I doing wrong? Did I follow the steps properly to set up Maven?
EDIT:
MVN Bin Directory path is:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
I tried all the manual steps here and still couldn't get it to work. Then I realized I can easily install it using Homebrew, much more convenient:
brew install maven
that's all you need to install maven for mac!
The $PATH is what point where your programs are, because of that you change it in order to find mvn. Actually you are pointing $PATH to $M2_HOME/bin.
You need to update $M2_HOME to one directory level before mvn bin and before update $PATH.
If this is your mvn home:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
you should use this env vars:
export M2_HOME="/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_60"
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH"
You can also edit your ~/.profile in order to include these lines, so you don't need to type these exports whenever you open your terminal.
Do
export M2_HOME=/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9

Issue while running ant command

I installed ant in my system, when I run ant command, I get following error:
Error: JAVA_HOME is not defined correctly. We cannot execute
/usr/lib/jvm/java-6-sun/bin/bin/java
Please suggest what should I do?
Set the environment variable JAVA_HOME to the installation directory of your JDK, which is: /usr/lib/jvm/java-6-sun
It looks like you have set it to /usr/lib/jvm/java-6-sun/bin (note the /bin at the end); the ant command appends another /bin so that you get .../bin/bin/java which is incorrect.
In your Java installation directory, u can see a jre subdirectory that contains the bin directory that contains java and related executables.
So you should probably be setting JAVA_HOME to /usr/lib/jvm/jdk/jre rather than /usr/lib/jvm/jdk.

Error while installing Elasticsearch on Windows

I have setup the Java path and I tried to run ElasticSearch on Windows 7. But I'm getting this error:
"no java.exe found on C:\Program Files\Java\jdk1.7.0_17\bin\".
I can run java & javac, they work fine.
How do I solve this issue?
So, I've kept hitting this problem and the solution is twofold. Like Udit said your Java_Home path should not include the bin folder (the reason being that the elastic search bat file seems to add on the bin folder manually, so if you add it the path would be bin\bin)
The second thing to check for is spaces in your path. If Java is installed to C:\Program Files then use C:\Progra~1 and if it's in C:\Program Files (x86) then use C:\Progra~2.
This should mean your Java_Home is set to something like C:\Progra~1\Java\jre7
To Verify this works open a command prompt and type %Java_Home%\bin\java and press return, you should then see all the command line parameters for Java listed. If you get this far you should be able to just run elasticsearch.bat
JAVA_HOME is the environment variable that points to Java installation directory.
Example: If u have installed Java in 32 bit windows 7 operating system, it would have installed in
C:/Program Files/Java/jdkx.x.x
This path should be put as JAVA_HOME. Probably you have set the path till bin directory i.e. C:/Program Files/Java/jdkx.x.x/bin
that is why it cannot find the java.exe.

Can't run mvn command on windows from unpacked source archive

My laptop got stolen so I had to redownload Java and Maven and I can't seem to get Maven up and running, even though I had no problems last time. I have the following locations:
C:\Program Files\Java\jdk1.7.0_03
C:\Program Files\apache-maven-3.0.4
In my environment settings, I added the following system variables:
M2_HOME - C:\Program Files\apache-maven-3.0.4
JAVA_HOME - C:\Program Files\Java\jdk1.7.0_03
I updated my Path system variable so that the following would be at the beginning:
%JAVA_HOME%\bin;%M2_HOME%\bin;
All this I got from the Maven installation instructions. However, when I open a new command prompt and check the version, I get the following message:
'mvn' is not recognized as an internal or external command,
operable program or batch file.
Does anyone know what I am missing?
UPDATE
When I installed Java, I noticed java -version automatically started working without me having to do anything. Might there be a Java conflict somewhere?
Your path variable should have %M2_HOME%\bin instead of %M2%\bin
Check the properties of mvn.bat to see if it is blocked.

Categories