java and maven installed on linux agent and set environmental variables permanently still facing maven is not installed error

Suneel Kumar Boyapati 0 Reputation points
2024-08-22T11:54:22.9866667+00:00

Maven

View raw log

  1. Starting: Maven ============================================================================== Task : Maven Description : Build, test, and deploy with Apache Maven Version : 4.243.1 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/maven ============================================================================== Maven is not installed on the agent /usr/bin/mvn -version The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program. ##[error]Build failed. ##[error]Exit code 1 returned from process: file name '/home/azureuser/myagent/externals/node20_1/bin/node', arguments '"/home/azureuser/myagent/_work/_tasks/Maven_ac4ee482-65da-7b085873e532/4.243.1/maventask.js"'. Finishing: Maven
  2. User's image

User's image

User's image

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,990 questions
Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
277 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Krishna Katakam 700 Reputation points Microsoft Vendor
    2024-08-22T15:52:04.92+00:00

    Hi Suneel Kumar Boyapati,Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    Here are some steps you can follow to resolve this issue:

    Check Maven Installation Path: Ensure that Maven is installed in the correct directory by running which mvn. This should return the path to the Maven executable.

    Update Environment Variables: Add the following lines to your .bashrc or .bash_profile file to ensure the environment variables are correctly set:

    export MAVEN_HOME=/path/to/your/maven
    export PATH=$MAVEN_HOME/bin:$PATH
    

    Replace /path/to/your/maven with the actual path to your Maven installation. Then, run source ~/.bashrc to apply the changes.

    Verify Permissions: Ensure that the user running the Maven command has the necessary permissions to access the Maven and JAVA_HOME directories.

    Check for Multiple Java Installations: If there are multiple Java installations, ensure that the correct Java version is being used by running java -version. Make sure the JAVA_HOME environment variable points to the correct Java installation.

    Restart the System: Sometimes, a system restart may be required for the changes to take effect. Please restart your system and verify if the issue persists.

    If you have any further queries, do let us know. If the comment is helpful, please click "Upvote".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.