In this blog, we will cover how to use maven without Admin access through cmd on Windows OS 10 & older versions.
Prerequisites
JAVA is installed (check C:\Program Files\Java\)
Apache Maven zip
Download Apache Maven directly from here or choose the latest zip file from here.
For Windows 10
For Windows 10 users, user can update Environment Variable for logged in Account, which doesn’t requires Admin access. Search for “Edit Environment variables for your Account” in windows search bar and add following properties
Create a .bat file that will help to add MAVEN and JAVA path on cmd startup.
In your User’s Home dir (C:\Users\username) add env.bat file with below content
@echo off
if "%MAVEN_HOME%"=="" (
echo Setting environment...
) else (
echo Environment already defined.
exit /b
)
set MAVEN_HOME=C:\Users\loggedinuser\Documents\apache-maven-3.6.3
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202
set path=%MAVEN_HOME%\bin;%path%
set path=%JAVA_HOME%\bin;%path%
Note: Don’t forget to update MAVEN_HOME and JAVA_HOME Path based on your system setup
Our bat file is ready, we just need to link it to cmb on startup.
cmd shortcut
Create a shortcut of cmd on Desktop
Steps:
Goto C:\WINDOWS\system32/
Select cmd => Right Click => Send To => Desktop
cmd Shortcut will be created on your desktop
Right-click newly created cmd Shortcut
Select Properties from the menu (last option)
A new window will pop up
In target path append “-cmd /K env.bat”
Sample Path should look like this (%windir%\system32\cmd.exe -cmd /K env.bat)
Maven Maven is a build automation tool used primarily for Java projects. Consider a project consisting of 100s and 1000s of Java file. need to compile each and every .java file for .jar packing. Similarly, Read more…
0 Comments