N
The Daily Insight

How do I point a Maven to a different JDK?

Author

Matthew Wilson

Updated on February 25, 2026

To change the Java version of the maven, we need to add the Java 8 home path to the JAVA_HOME env variable. To do that we need to run the command: export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8. jdk/Contents/Home in the terminal.

How does Maven know which JDK to use?

4 Answers. mvn -version will output which java it’s using. If JAVA_HOME is set to a valid JDK directory and Maven is using something else, then most likely someone has tampered with the way that Maven starts up. You can define the Java to be used with maven.

How do I fix java Release 5 not supported?

1. Update Java Compiler

  1. Go to IntelliJ IDE menu item (or File on Windows) -> Preferences -> Build, Execution, Deployment -> Java Compiler.
  2. Delete value under Target bytecode version, then click OK.
  3. Refresh maven.
  4. Try running again. If problem persists, continue on to number 2 below.

Which java version does Maven use?

With Maven, if you do not specify any compiler version explicitly, Maven uses Java 1.5 compiler version. Before move on ahead, let’s understand how to compile java code in specific compiler version using JDK.

Does Maven need JDK or JRE?

Maven needs a JDK, and not a JRE.

Do I need JDK to run Maven?

Can I use JDK instead of JRE?

Maven requires Eclipse using a JDK, i.e. Java Development Kit, instead of a Java Runtime Environment (JRE). The main difference is that a JDK also contains a Java Compiler and other tools to develop Java Code, while the JRE is only able to run compiled Java applications.

Does Maven need JDK?

Maven needs a JDK, and not a JRE. Maven requires JDK for compilation. To check if you have JDK compiler you can type: javac in terminal. Also asked, can we use JRE instead of JDK? Run Eclipse with a JDK. Maven requires Eclipse using a JDK, i.e. Java Development Kit, instead of a Java Runtime Environment (JRE).

How to install Maven?

JDK and JAVA_HOME. Make sure JDK is installed,and JAVA_HOME environment variable is configured.

  • Download Apache Maven. 2.1 Visit Maven official website,download the Maven zip file,for example : apache-maven-3.6.0-bin.zip.
  • Add MAVEN_HOME system variable.
  • Add %MAVEN_HOME%\\bin To PATH.
  • Verification.
  • FAQs.
  • What are the different versions of JDK?

    – Versions 1.0 and 1.1 are named as JDK (Java Development Kit). – From versions 1.2 to 1.4, the platform is named as J2SE (Java 2 Standard Edition). – From versions 1.5, Sun introduces internal and external versions. – From Java 6, the version name is Java SE X.

    How to run Maven from Java?

    Build&Run Maven Project. Go to the project folder,in my environment it is C:\\WorkSpace\\MvnExampleProject\\dev2qaExample Open a command prompt and run the command mvn clean package.

  • Add Other Java File To Maven Project. Create AppUtil.java file as below.
  • Add TestNG jar File To Maven Java Project.