Languages
[Edit]
EN

Bash - run mvn command using specific Java version

7 points
Created by:
Broncono
466

In this short article, we would like to show how to run mvn command using specific Java version.

Quick solution (run the command):

JAVA_HOME=/path/to/jdk mvn -version

 

Practical example

In this section Java 11 was used to run Maven version and related details.

JAVA_HOME="/c/Program Files/Java/OpenJDK/jdk-11.0.10.9-hotspot" mvn -version

Example output:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\apache-maven-3.6.3
Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: C:\Program Files\Java\OpenJDK\jdk-11.0.10.9-hotspot
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

 

Other variants

JAVA_HOME="/c/Program Files/Java/OpenJDK/jdk-11.0.10.9-hotspot" mvn clean compile
JAVA_HOME="/c/Program Files/Java/OpenJDK/jdk-11.0.10.9-hotspot" mvn clean package
JAVA_HOME="/c/Program Files/Java/OpenJDK/jdk-11.0.10.9-hotspot" mvn clean install

# etc.

 

Alternative titles

  1. Bash - run Maven command using specific Java version
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join