Home Java javaTutorial A guide to setting Maven environment variables

A guide to setting Maven environment variables

Jan 28, 2024 am 09:51 AM
environment variables maven Configuration

A guide to setting Maven environment variables

Maven environment variable configuration tutorial, specific code examples are required

Maven is a powerful project management tool that can simplify the construction and management process of Java projects. In order to use Maven normally, we need to correctly configure Maven's environment variables. This tutorial will take you step by step to understand how to configure Maven environment variables, and give code examples to help you complete the configuration on different operating systems.

1. Windows system configuration

  1. Download the Maven installation package

First, you need to download the Maven installation package from the official website of Maven (https://maven.apache .org/) to download the latest Maven installation package. Select the version suitable for your Windows system and download the installation package.

  1. Extract the installation package

Extract the downloaded Maven installation package to a directory on your computer. Assume that the decompression path is: C: pache-maven-3.8.4.

  1. Configure environment variables

Open "Control Panel" -> "System and Security" -> "System", click "Advanced System Settings" on the left .

In the "System Properties" window, click the "Advanced" tab, and then click the "Environment Variables" button below.

In the "Environment Variables" window, find the "Path" variable under "System Variables" and click "Edit".

In the "Edit Environment Variables" window, click the "New" button and enter the following:
C: pache-maven-3.8.4 in

Click "OK" " button to save the configuration.

  1. Verify configuration

Open the command prompt (CMD) window and enter the following command:
mvn -v

If the command line output The Maven version information indicates that the Maven environment variables are configured successfully.

2. Linux system configuration

  1. Download the Maven installation package

Similarly, you need to download the latest Maven installation package from the Maven official website. Select the version suitable for your Linux system and download the installation package. Assume that the download path is: /home/user/Downloads/apache-maven-3.8.4.tar.gz.

  1. Extract the installation package

In the terminal, use the following command to decompress the Maven installation package:
tar zxvf /home/user/Downloads/apache-maven-3.8 .4.tar.gz

After decompression is completed, you will get a directory named apache-maven-3.8.4.

  1. Configure environment variables

In the terminal, use a text editor to open the bashrc file:
vi ~/.bashrc

At the end of the file Add the following code:
export MAVEN_HOME=/home/user/Downloads/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin

Save and close the file.

  1. Effective configuration

In the terminal, run the following command to make the environment variable configuration take effect:
source ~/.bashrc

  1. Verify configuration

In the terminal, enter the following command:
mvn -v

If the command line outputs Maven version information, it means that the Maven environment variable is configured successfully.

3. Mac system configuration

  1. Download the Maven installation package

Similarly, download the latest Maven installation package from the Maven official website and select the Mac system version and download the installation package. Assume that the download path is: /Users/user/Downloads/apache-maven-3.8.4.tar.gz.

  1. Extract the installation package

In the terminal, use the following command to decompress the Maven installation package:
tar zxvf /Users/user/Downloads/apache-maven-3.8 .4.tar.gz

After decompression is completed, you will get a directory named apache-maven-3.8.4.

  1. Configure environment variables

In the terminal, use a text editor to open the bash_profile file:
vi ~/.bash_profile

At the end of the file Add the following code:
export MAVEN_HOME=/Users/user/Downloads/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin

Save and close the file.

  1. Effective configuration

In the terminal, run the following command to make the environment variable configuration take effect:
source ~/.bash_profile

  1. Verify configuration

In the terminal, enter the following command:
mvn -v

If the command line outputs Maven version information, it means that the Maven environment variable is configured successfully.

Summary:
Whether it is Windows, Linux or Mac system, correctly configuring Maven environment variables is a key step to make Maven work properly. This tutorial details how to configure Maven environment variables under different operating systems, and provides specific code examples to help you complete the configuration. I hope this tutorial will be helpful to you and allow you to use Maven for project management more smoothly.

The above is the detailed content of A guide to setting Maven environment variables. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The working principle and configuration method of GDM in Linux system The working principle and configuration method of GDM in Linux system Mar 01, 2024 pm 06:36 PM

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

How to configure python environment variables in Win11? Tips for adding environment variables in win11python How to configure python environment variables in Win11? Tips for adding environment variables in win11python Feb 29, 2024 pm 04:30 PM

Win11 system is the latest Windows operating system, and users may encounter some configuration problems when using it. Among them, configuring Python environment variables is a common requirement because it allows users to easily use Python commands from any location. This article will introduce how to configure Python environment variables in Win11 system so that users can use the Python programming language more conveniently. 1. [Right-click] this computer on the desktop, and select [Properties] in the menu item that opens; 2. Then, under related links, find and click [Advanced System Settings]; 3. In the system properties window, click [Environment] at the bottom Variables]; 4. In the environment variables window, under system variables, select [Path], and then click

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

Java Maven build tool advancement: optimizing compilation speed and dependency management Java Maven build tool advancement: optimizing compilation speed and dependency management Apr 17, 2024 pm 06:42 PM

Optimize Maven build tools: Optimize compilation speed: Take advantage of parallel compilation and incremental compilation. Optimize dependencies: Analyze dependency trees and use BOM (bill of materials) to manage transitive dependencies. Practical case: illustrate optimizing compilation speed and dependency management through examples.

How to configure and install FTPS in Linux system How to configure and install FTPS in Linux system Mar 20, 2024 pm 02:03 PM

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

MyBatis Generator configuration parameter interpretation and best practices MyBatis Generator configuration parameter interpretation and best practices Feb 23, 2024 am 09:51 AM

MyBatisGenerator is a code generation tool officially provided by MyBatis, which can help developers quickly generate JavaBeans, Mapper interfaces and XML mapping files that conform to the database table structure. In the process of using MyBatisGenerator for code generation, the setting of configuration parameters is crucial. This article will start from the perspective of configuration parameters and deeply explore the functions of MyBatisGenerator.

The usage of environment variables in Linux is divided by the same life cycle The usage of environment variables in Linux is divided by the same life cycle Mar 25, 2024 am 08:00 AM

Preface: 1. Environment variables are variables set by the operating system environment and are applicable to the user process of the entire system; 2. Environment variables can be set in commands, and the setting values ​​will be lost when the user logs off; 3. To If it is repeatedly applicable, it is best to define it in .profile; the use of environment variables is the same as the use of local variables. 4. And before use, it must be imported with the export command. 1. Introduction to environment variable files. Environment variables in Linux include system level and user level. System-level environment variables are system variables that every user who logs in to the system must read, while user-level environment variables are the system variables that the user uses. Environment variables are loaded at the time, so the files that manage environment variables are also divided into system level and user level. 2. L

What files do Linux environment variables come from? What files do Linux environment variables come from? Mar 20, 2024 pm 07:50 PM

In the Linux environment, after the LinuxShell login is successful, Linux will obtain a series of data from the file for the login. This data will be used in individual instructions or individual programs. That data is called the LinuxShell runtime environment. Data in the environment can be roughly divided into four types: environment variables, Shell variables, aliases, and Shell functions. Among them, Shell variables, aliases, and Shell functions will not be explained in detail here. What are the environment variables? You can directly use the printenv command without parameters to output the environment variables of the current session and the values ​​of the environment variables. If parameters are added, the value of a certain variable is output. If it were more convenient to view

See all articles