Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: -classpath requires class path specification

I have installed Maven and I did all steps, but when I tried to execute it, I see in cmd this error -> Error: -classpath requires class path specification

My environment variables are these:

JAVA_HOME C:\Program Files\Java\jdk-9.0.4

M2 C:\apache-maven-3.5.2\apache-maven\src\bin

M2_HOME C:\apache-maven-3.5.2\apache-maven\src

You can see my Path here:

Path

And executable files are here:

mvn files

As you can see, maven files are in C:\apache-maven-3.5.2\apache-maven\src\bin so, for this reason, I have these environment variables. Likewise, I have tried with "standard" path from all the solution of Internet, but it doesn't work. (As standard I mean C:\apache-maven-3.5.2 and C:\apache-maven-3.5.2\bin)

What am I doing bad? If i change this path of evironment variables, I get a "can't recognize the command"

Thanks for all, waiting for your answers!

EDIT - SOLUTION

I downloaded source files from Maven and I should have downloaded binary files. With binary files and these environtment variables it works perfectly:

JAVA_HOME C:\Program Files\Java\jdk-9.0.4

M2 C:\apache-maven-3.5.2\bin

M2_HOME C:\apache-maven-3.5.2

like image 811
msabate Avatar asked Mar 01 '18 09:03

msabate


2 Answers

WINDOWS USERS SOLUTION:

  1. Downloaded the apache software from here: https://maven.apache.org/download.cgi. I chose the "Binary Zip Archive".

  2. Unpack contents to your desired directory. My standard directory is C:\Program Files (after unpacking, the path to the bin folder should look like this --> C:\Program Files\apache-maven-3.5.3\bin

  3. Create environmental variables: press windows button and pause button. Select "Advanced system settings". For User Variables create the following:

    Variable Name: M2 Variable Value: C:\Program Files\apache-maven-3.5.3

    Variable Name: M2_HOME Variable Value: C:\Program Files\apache-maven-3.5.3

For System Variable, select the existing "PATH" variable and select "Edit." Select "New" and type C:\Program Files\apache-maven-3.5.3\bin

Assuming you already have Java and JDK setup, go to Command Prompt in your computer and type mvn -version. It should show you the version information.

like image 87
Scott Davis Avatar answered Nov 13 '22 20:11

Scott Davis


First I assumed you already have Java and JDK setup, go to Command Prompt in your computer and check %JAVA_HOME%

You have already download apache-maven-3.x.y.bin (I wrote this especially because of my problem with apache-maven-3.x.y.src). So, my first advice you should download binary files.

Now, you can go to ENVIRONMENT VARIABLES, and add variable name M2_HOME and add variable name MAVEN_HOME with your maven directory, of course. Example: variable value: c:\Program Files\apache-maven-3.x.y

Now, you can test the variables on your Command Prompt like that:

echo %MAVEN_HOME%
echo %M2_HOME%

Then you have to set bin directory to your PATH variable on ENVIRONMENT VARIABLES. For System Variable inside the ENVIRONMENT VARIABLES, select the existing "PATH" variable, and select "Edit." Select "New" and type %M2_HOME%\bin

Another way using Command Prompt example: Add the bin directory to your PATH:

set PATH="%M2_HOME%\bin"
like image 30
Alper Guven Avatar answered Nov 13 '22 19:11

Alper Guven