How to check which version of Java, Maven, Gradle - java

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)

Related

Warning: JAVA_HOME environment variable is not set

My OS is Windows 10. I had an error when starting the .\artemis in the Windows PowerShell. It said:
Warning: JAVA_HOME environment variable is not set.
I already setting the JAVA_HOME's path at C:\Program Files\Java\jdk-19\bin. This is the result for echo %JAVA_HOME%:
C:\Program Files\Java\jdk-19\
I tried to test the mvn -v:
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\apache-maven-3.8.1\bin\..
Java version: 19.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-19
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
(it should not be shown if the JAVA_HOME is not set tho)
I tried the java -version:
java version "19.0.1" 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
The javac -version:
javac 19.0.1
Can someone explain how to fix it?
I forgot to mention it
when I use git bash to run ./artemis the result is
./artemis: line 93: C:\Program Files\Java\jdk-19;/bin/java: No such file or directory
Install and set Java SDK 11 as JAVA_HOME.
Most applications will not work with SDK 18 or higher.
Artemis notes:
Note on Java versions: The old v17.0.1 version of the Artemis software required Java version 1.8 to run. All recent releases from v18.0.0 onwards require a minimum of Java 9 and ideally Java 11. This must be installed first.
Extracted from http://sanger-pathogens.github.io/Artemis/
Did you try using the short name? It’s been some time since I used Windows but
if I recall correctly I used to use PROGRA~1 instead of "Program files".

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

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.

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!

maven ignoring jenv settings

I had OSX with Java 1.6 installed, and I just installed jenv along with Java 1.7:
$ jenv local '1.7'
$ jenv versions
system
1.6
1.6.0.65
* 1.7 (set by /Users/me/workspace/.java-version)
1.7.0.79
oracle64-1.6.0.65
oracle64-1.7.0.79
jenv is doing its job, with $ java -version always working, showing 1.6 when I've set it to 1.6, and 1.7 when I've set it to 1.7:
$ java -version
java version "1.7.0_79" <--------------------------------- YAY!!
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
... but maven is ignoring my settings:
$ mvn -version
Apache Maven 3.0.2 (r1056850; 2011-01-08 19:58:10-0500)
Java version: 1.6.0_65, vendor: Apple Inc. <--------------------------------- BAH!!
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"
I found this SO question where the guy just needed to hardcode his JAVA_HOME inside .mavenrc, but I don't want mine hard-coded (thus jenv!), and I don't have a ~/.mavenrc, nor an /etc/mavenrc.
The version it's using seems to be from whatever's first on the /usr/libexec/java_home output, so in the short term I was able to get 1.6 back again by tweaking 1.7's Info.plist file (from this SO post), but that just means I get 1.6 instead of 1.7.
Any ideas?
You need to install the jenv maven plugin, try the following command and reload your shell:
jenv enable-plugin maven
I had a similar problem. I got things running by prefixing all command with jenv exec:
jenv exec mvn -version
Now, there's a new option how to set JAVA_HOME via jenv export plugin:
jenv enable-plugin export
See https://github.com/gcuisinier/jenv/issues/44#issuecomment-233124185
If you have enabled the maven and export plugins, and still have problems, check that you don't have a ~/.mavenrc file which is setting JAVA_HOME.
If jenv enable-plugin export still doesn't work then you should restart the Terminal and try again

Categories