Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Apache Maven Cookbook
  • Toc
  • feedback
Apache Maven Cookbook

Apache Maven Cookbook

By : Raghuram Bharathan
4.2 (5)
close
Apache Maven Cookbook

Apache Maven Cookbook

4.2 (5)
By: Raghuram Bharathan

Overview of this book

If you are a Java developer or a manager who has experience with Apache Maven and want to extend your knowledge, then this is the ideal book for you. Apache Maven Cookbook is for those who want to learn how Apache Maven can be used for build automation. It is also meant for those familiar with Apache Maven, but want to understand the finer nuances of Maven and solve specific problems.
Table of Contents (13 chapters)
close
12
Index

Changing the JDK used by Maven

It is possible to have more than one version of JDK installed on your system. By following some simple steps, you can specify and/or change the JDK to be used by Maven.

How to do it...

You will recall that, in the earlier section, we used Java SE 7. Let us now change to Java SE 8. To change the JDK version to Java SE 8 on Microsoft Windows, perform the following steps:

  1. From the command prompt, run the following command:
    set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_20
    
  2. For Linux or Mac, the command will be:
    export JAVA_HOME=<java-8-home-folder>
    
  3. Now, run the following command to check the version of Maven installed:
    mvn –version
    
  4. To check the version of Maven installed on Microsoft Windows, run the following command from the command prompt. You should get the following output. The output will be similar for Linux and Mac:
    C:\projects\apache-maven-cookbook>mvn -version
    

    The output for the preceding command is shown as:

    Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T22:59:23+05:30)
    Maven home: C:\software\apache-maven-3.2.5
    Java version: 1.8.0_20, vendor: Oracle Corporation
    Java home: C:\Program Files\Java\jdk1.8.0_20\jre
    Default locale: en_IN, platform encoding: Cp1252
    OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
    

How it works...

Maven always uses the JDK specified by JAVA_HOME, no matter how many JDK installations are available on the system. This allows the user the flexibility to change JDKs as required or based on the project.

Hence, it is important to ensure JAVA_HOME is defined. In the absence of this variable, Maven attempts to detect the presence of Java from PATH. This is typically JRE and not JDK.

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete