3

I want to use Maven for my project.

In my office computer , I don't have the Admin privilege . Hence I am not able to set the "System Variable". I have access only to "User Variable" where I can set only the Java_Home.

Can I use Maven without adding the M2_Home and editing the Path variable ?

Kannan C
  • 93
  • 2
  • 3
  • 9
  • Is this on Windows? You should be able to just create a PATH variable in your user variables. In fact it should already be there. https://superuser.com/questions/133263/windows-7-user-specific-path – Gimby Jun 09 '17 at 13:12
  • Yes, It is Windows. PATH variable is already there with the value %JAVA_HOME%/bin – Kannan C Jun 09 '17 at 13:21
  • So you can just add the maven bin path to it. No need to add any system variable at all. – Gimby Jun 09 '17 at 14:08

5 Answers5

3

It depends if you are using it inside an ide or building project from terminal.

  • If you are using an IDE, there is probably an embedded maven ( there is one inside Eclipse and Intellij IDEA)
  • If you are building using CLI you can invoke maven using the full path for instance :

    /home/<your_folder>/tools/apache-maven-3.5.0/bin/mvn clean install from your project path

Haythem ROUIS
  • 347
  • 2
  • 10
  • I am using Eclipse Luna Service Release 2 (4.4.2) and it has embedded Maven. When try to create a Maven Project, getting an error "Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: etc......" – Kannan C Jun 09 '17 at 12:50
  • Can you check the maven installation inside your Eclipse ? You can find it in the menu : Window > Preferences > Maven > Installations. Make sure it is pointing to the embedded maven. [see this question](https://stackoverflow.com/questions/31316339/how-to-solve-maven-2-6-resource-plugin-dependency) – Haythem ROUIS Jun 09 '17 at 13:33
  • Check the thread in my previous comment and make sure , you are correctly setting your maven configuration. Also check if you don't have a proxy blocking your eclipse from connecting to the maven repo. – Haythem ROUIS Jun 09 '17 at 13:41
  • @HaythemROUIS is this possible in `Windows` too? – Kasun Siyambalapitiya Nov 08 '17 at 07:01
  • Yes it does not depend on your OS. – Haythem ROUIS Nov 08 '17 at 08:30
1

You could set the M2_HOME user variable even you are not an administrator, and the variable path is unnecessary, you could easily do the same task referencing the maven fullpath bin directory.

fdam
  • 820
  • 1
  • 11
  • 25
0

Sure you can, you just need to build your project from maven home actualy

Here is an example from stackoverflow

0

If you don't have admin rights, simply set the path till Maven's bin in lets say MAVEN_HOME in user variables. MAVEN_HOME

Then go to the Path variable in user variables and add MAVEN_HOME to it. enter image description here

You are all set then, just go to command prompt and type mvn -version and you should be good with maven setup in your system.

Anvita Shukla
  • 409
  • 7
  • 7
0

We can add .bat file and link it to cmd by default so whenever you open the terminal that code will execute and set your variable

You can refer more in detail here.

Update:

For Windows 10 user can add detail for your account and doesn't require admin access. Search for below text in windows search bar

Edit Environment variables for your Account

MyTwoCents
  • 7,284
  • 3
  • 24
  • 52