Intellij 'mvn' is not recognized as an internal or external command - java

I have installed maven on my pc and if I type "mvn --version" in the cmd, I get:
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T14:57:37+03:00)
Maven home: C:\Users\mmmm\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_251\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
The problem is that from Intellij, if I try to do a mvn clean install from the terminal, I get "'mvn' is not recognized as an internal or external command,
operable program or batch file."
My system variables contain these:
M2_HOME = C:\Users\mmmm\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3
M2 = %M2_HOME%\bin
Path = %M2_HOME%\bin
How can I fix this?

I have also installed JDK 1.8 and Maven3 as below:
>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
>javac -version
javac 1.8.0_121
>mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\SDK\maven\apache-maven-3.6.3\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation, runtime: C:\java\jdk1.8\jre
Default locale: en_US, platform encoding: MS932
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
I found the problem is the environment variables of terminal:
Copy your bin path of JDK and Maven into it!! And then restart your Terminal.

I had a similar issue that was fixed after I pointed M2_HOME to Intellij's maven plugin path instead of pointing to a path associated with a separate maven installation.
"C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\plugins\maven\lib\maven3"
I also added %M2_HOME%\bin to PATH.

Related

Is JAVA_HOME not required anymore for recent versions of Maven?

Few days ago, I observed, that mvn -version runs successfully even without having JAVA_HOME defined. As I remember, historically, all Maven versions needed JAVA_HOME.
So, I've played a bit, downloaded different versions of Maven and tested them.
It turns out, that Maven versions <= 3.5.3 were in a need of JAVA_HOME in order to know where to refer for running Java runtime; however, Maven versions >= 3.5.4 do not anymore necessarily need JAVA_HOME and they run fine without it.
Moreover, mvn -version with any Maven <= 3.5.3 prints:
Apache Maven 3.5.3 (f9f2937f9f29f9f293df5050c2f9f29f9f295297; 2018-02-24T21:49:05+02:00)
Maven home: C:\apache-maven-3.5.3\bin\..
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: c:\jdk1.8.0_251\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
while mvn -version with any Maven >= 3.5.4 prints:
Apache Maven 3.6.0 (11c987ce5ffb2f3e7767ce5ffb20915ffb20c987; 2018-10-24T21:41:47+03:00)
Maven home: C:\apache-maven-3.6.0-bin\bin\..
Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: c:\jdk1.8.0_251\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
First is with JAVA_HOME and second - without.
So, do we still need to be providing JAVA_HOME for Maven in the future or not?
If yes - how it works without JAVA_HOME?
If no - why? because of what exact reason?
From https://maven.apache.org/install.html
Have a JDK installation on your system. Either set the JAVA_HOME
environment variable pointing to your JDK installation or have the
java executable on your PATH.

Apache tika and apache ctakes

~$ java -version
java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)
~$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: /opt/maven
Java version: 1.8.0_212, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-37-generic", arch: "amd64", family: "unix"
apache tika 1.23
apache ctakes 3.2.2
ubuntu 16.04 LTS
I have followed the steps on the official site.
while the step
java -classpath $HOME/src/ctakes-config:${TIKA_HOME}/tika-app/target/tika-app-X.Y-SNAPSHOT.jar:${CTAKES_HOME}/desc:${CTAKES_HOME}/resources:${CTAKES_HOME}/lib/\* org.apache.tika.cli.TikaCLI --config=$HOME/src/ctakes-config/tika-config.xml -m Vose-2013-American_Journal_of_Hematology.pdf
I am getting this error:
Error: Could not find or load main class org.apache.tika.cli.TikaCLI
please help
Probably you did not set the variables TIKA_HOME and/or CTAKES_HOME in the environment you want to run the command.

Build Jenkins and deploy on Heroku

Uninstalled all version of java from my machine and reinstalled the version 7 of Oracle:
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ mvn -v
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: pt_BR, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-61-generic", arch: "amd64", family: "unix"
why when using the foreman start the application works locally and when I do the build by Jenkins and implant in heroku the application launches java.lang.UnsupportedClassVersionError exception and Unsupported major.minor version 51.0? I'm using the wrong dependence? Where am I wrong?
I'm not getting solve this problem.
Any help will be very welcome!

How to check which version of Java, Maven, Gradle

How to check which version of Java, Maven, Gradle, NodeJs installed on your machine and how to set environment variables for all these building tools or JDK ?
Goto your CMD (for Windows) or shell terminal (for linux / ubuntu)
To check which Java version and compiler version installed:
C:\>java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
Here you can check compiler version
C:\>javac -version
javac 1.7.0_71
To check which version of Maven installed: Use(mvn -v or mvn version)
C:\>mvn -v
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T22:59:23+05:30)
Maven home: C:\apache-maven-3.2.5
Java version: 1.7.0_71, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_71\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
To check which version of Gradle installed:
C:\>gradle -version
------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_71 (Oracle Corporation 24.71-b01)
OS: Windows 7 6.1 amd64
To check which version of node installed:
C:\>node -v
v0.12.0
Setting environment variables for
1) JAVA
Windows: Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21
Linux: export JAVA_HOME=/usr/local/java-current
2) Maven
(extract distribution here (You can extract any where you want)
Windows: C:\Program Files\Apache Software Foundation\apache-maven-3.2.1
Linux: /usr/local/apache-maven
Windows:-
M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-2.2.1
M2=%M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m
Linux:
Open command terminal and set environment variables.
export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m -Xmx512m
3)

How do I install new Java Development Kit (JDK) on MAC OSX Mavericks?

How do I install new Java Development Kit (JDK) on MAC OSX Mavericks?
I tried to follow the apache instructions, but failed miserably.
In case anyone is installing Maven on a 64-bit Mac running Mac OSX 'Mavericks'. I was trying to follow this, which failed because the location of the java_home has changed on Mavericks:
http://maven.apache.org/download.cgi
I found this website, which recommends you Install homebrew and follow the instructions on this page: http://techspunky.blogspot.in/2013/10/how-to-install-maven-on-mac-osx-109.html
once complete, don't panic when $ maven -version doesn't work, instead use $mvn --version as maven.apache.org/download.cgi recommended.
It worked, but then I noticed the Java SDK Maven was using was Java version: 1.6.0_65, which is not the latest SDK I installed on the system.
Once I set the JAVA_HOME=/usr/libexec/java_home
It was using the correct SDK:
Maven home: /usr/local/Cellar/maven/3.1.1/libexec
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
Success!
but wait...
next time I opened the terminal it went back to java version 1.6. WTH!
its some sort of supposed bug from what I read use:
echo JAVA_HOME=/usr/libexec/java_home -v 1.7 | sudo tee -a /etc/mavenrc
and now:
Maven home: /usr/local/Cellar/maven/3.1.1/libexec
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
Closed terminal re-opened and success!

Categories