My laptop got stolen so I had to redownload Java and Maven and I can't seem to get Maven up and running, even though I had no problems last time. I have the following locations:
C:\Program Files\Java\jdk1.7.0_03
C:\Program Files\apache-maven-3.0.4
In my environment settings, I added the following system variables:
M2_HOME - C:\Program Files\apache-maven-3.0.4
JAVA_HOME - C:\Program Files\Java\jdk1.7.0_03
I updated my Path system variable so that the following would be at the beginning:
%JAVA_HOME%\bin;%M2_HOME%\bin;
All this I got from the Maven installation instructions. However, when I open a new command prompt and check the version, I get the following message:
'mvn' is not recognized as an internal or external command,
operable program or batch file.
Does anyone know what I am missing?
UPDATE
When I installed Java, I noticed java -version automatically started working without me having to do anything. Might there be a Java conflict somewhere?
Your path variable should have %M2_HOME%\bin instead of %M2%\bin
Check the properties of mvn.bat to see if it is blocked.
Related
I have read similar questions about this problem but it is not working anyways.
I've extracted maven 3.3.3 to D:\Maven (Java already installed and works fine) then added 2 system variables:
Variable
Value
M2
%M2_HOME%\bin
M2_HOME
D:\Maven
I've also appended next in the path:
%M2%
But it is still not working.
I can execute mvn -version from the D:\Maven\bin but can't do this from another directory.
Don't put extra space in your path after D:\Maven\bin; in D:\Maven\bin; D:\Program Files\NodeJS; Please don't make any space in path variable.
Normally, To set mvn in command line in windows :
Set JAVA_HOME property in system environment
eg. JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65
Set M2_HOME property in system environment
eg. M2_HOME=D:\apache-maven-3.3.3
Finally add maven to PATH
;%M2_HOME%\bin; add this at the end of PATH property of system environment
Now Try mvn -version
Try to put full maven path upto bin like "C:\Users\ABC\Downloads\maven-2.0.5-bin\maven-2.0.5\bin" directly into path variable of os, then you will be able to understand where problem exists.
One mistake I did was, There will two environment variables section
One can be accessed via admin while the other one doesn't require any.
Please specify the paths in the second place
It will work for sure., also try echo %M2_HOME% to check whether you have configured correctly..before jumping to mvn install
Hope this helps for someone who has to use admin rights
Actually I tried to install Apache Maven to my system.
I followed these steps:
Downloaded apache-maven-3.3.3 in my Window 8 machine and copied to Program Files.
Then added maven path C:\Program Files\apache-maven-3.3.3 as M2_HOME in system variable and added C:\Program Files\Java\jdk1.8.0_31 as JAVA_HOME.
Then added ;%M2_HOME%\bin to default Path.
Then tried to run as mvn -version in CMD.
But I got the result like:
mvn is not recognized as an internal or external command...
I remember I had similar issue some time ago on Windows 7. On Windows 8 it may behave similarly. Your solution should work correctly, but for some reason it's not working.
Add path to bin/ directory inside your Maven directory to the Path system variable after semicolon. In your case it will be:
C:\Program Files\apache-maven-3.3.3\bin
Save Path variable, close terminal, run it again and type: mvn -version.
I installed ant in my system, when I run ant command, I get following error:
Error: JAVA_HOME is not defined correctly. We cannot execute
/usr/lib/jvm/java-6-sun/bin/bin/java
Please suggest what should I do?
Set the environment variable JAVA_HOME to the installation directory of your JDK, which is: /usr/lib/jvm/java-6-sun
It looks like you have set it to /usr/lib/jvm/java-6-sun/bin (note the /bin at the end); the ant command appends another /bin so that you get .../bin/bin/java which is incorrect.
In your Java installation directory, u can see a jre subdirectory that contains the bin directory that contains java and related executables.
So you should probably be setting JAVA_HOME to /usr/lib/jvm/jdk/jre rather than /usr/lib/jvm/jdk.
I know this question has been beaten to death but I still cannot get the SDK Manager to run on my Windows 7 Home.
I downloaded the eclipse + adt bundle. The SDK Manager.exe is in the sdk folder where I try to run it from. I even tried copying it to the tools folder and tried running from there but no luck.
The error I get is:
Failed to execute tools\android.bat:
The system cannot find the file specified.
The file clearly exists. I tried running it as "Administrator" as well.
Next I tried running the android.bat file itself which says:
Windows cannot find 'E:\path\to\batfile'.
Make sure you typed the name correctly, and then try again.
I then ran it as "Administrator" which at least detects and tries to execute it. I added in a few pause statements to android.bat itself to prevent it from closing.
Here is what I see:
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal
or external command, operable program or batch file.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java JDK installed on your system.
We recommend that you install the JDK version of JavaSE, available here:
http://www.oracle.com/technetwork/java/javase/downloads
If you already have Java installed, you can define the JAVA_HOME environment
variable in Control Panel / System / Avanced System Settings to point to the
JDK folder.
Not sure why it says that because when I run where java in cmd I get this:
C:\Users\(MyUser)>where java
C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\Windows\System32\java.exe
And when I open cmd and manually run
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s'
it works fine.
I then tried setting the java_exe in android.bat to
set java_exe=C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
After commenting out the find_java I ran it again and this is what I get:
'"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar lib\archquery.jar' is not
recognized as an internal or external command,
operable program or batch file.
Invalid path
And once again, when I manually run it, I get:
C:\Users\MyUser>"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar E:\ADT\sdk\t
ools\lib\archquery.jar
x86_64
Am I missing something or should I finally give up trying to get it to work on my windows machine.
Your where java shows too many java.exe, the find_java.bat will try to look for javaw as well in the folder where java is.
set JAVA_HOME and make sure the echo %PATH% points to your main jdk installation.
I have downloaded both Java jdk1.7.0_06 and Java jre7. and i added the following system variable JAVA_HOME C:\Program Files\Java\jdk1.7.0_06\bin to my windows 7. But when I type the following in the CMD command line on my windows 7 C:\activiti-5.10\activiti-5.10\setup>ant demo.start to run a demo application I got the following error in the command line '
"java.exe"' is not recognized as an internal or external command, operable program or batch file
So does anyone know how i can solve this problem ?
BR
If you look at the "ant.bat" file, you will see that it looks for the "java" command in the following way:
If the %JAVACMD% environment variable is set, then it uses that.
Otherwise, if the %JAVA_HOME% environment variable is set, it tries to use %JAVA_HOME%\bin\java.exe
Otherwise, it tries to use java.exe; i.e. it will look on your %PATH%.
In your case, you have %JAVA_HOME% set ... but set to the Java installation's "bin" directory, not to the root of the installation. So the Ant.bat script looks in the wrong place for java.exe.
Just set %JAVA_HOME% correctly, and it should work.
JAVA_HOME C:\Program Files\Java\jdk1.7.0_06
As you can see from the above, you do not need to have the Java "bin" directory on your %PATH% for Ant to work, but it is a good idea to set it anyway. That way you can run the Java commands simply from the command line.
The setting of %CLASSPATH% is not relevant to this problem. Indeed, unless the build.xml file is broken, Ant will ignore your %CLASSPATH% environment variable.
You need to put the file java.exe in your PATH variable but the JRE in JAVA_HOME
JAVA_HOME is the path of JDK root folder.eg: C:\Program Files\Java\jdk1.7.0_06 but path define C:\Program Files\Java\jdk1.7.0_06\bin
JAVA_HOME C:\Program Files\Java\jdk1.7.0_06
JRE_HOME C:\Program Files\Java\jre1.7.0_06
path = C:\Program Files\Java\jdk1.7.0_06\bin;C:\Program Files\Java\jre1.7.0_06\bin
Typically JAVA_HOME should be the parent directory of the "bin" folder.(jre or jdk)
In this case ant expects the java to be from the JDK.
try following in a cmd window
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_06
set path="%JAVA_HOME%/bin;%path%;
ant
(side note: adding java.exe to path is not a requirement for ant; it is a convenience thing for the user)
Just delete the following set of files from your %windir/System32 folder. Actually deleting java.exe is enough but for consistency sake just delete all the java related binaries.
java.exe
javaw.exe
javaws.exe
Actually oracle windows installer places a copy of these files into %windir/System32 folder (which I don't understand why) but looks like they are not needed (as they are available anyway under JDK folder where you install them).
I have tried all the various solutions posted in the SO and other forums as well but none of them worked for me. I have also set all the relevant environment variables (JAVA_PATH, CLASS_PATH etc) correctly as well. Finally this is the only solution that has worked for me.
Go to the \squirrel-sql-3.9.0>squirrel-sql.bat .open that squirrel-sql.bat in Notepad and comment out the existing logic which is
=======================================
if exist "%IZPACK_JAVA%\bin\javaw.exe" (
set LOCAL_JAVA=%IZPACK_JAVA%\bin\javaw.exe
) else (
set LOCAL_JAVA=javaw.exe
)
echo Using java: %LOCAL_JAVA%
=================================
and add the below logic
#echo off
set LOCAL_JAVA=C:\Program Files (x86)\Java\jre7\bin\javaw.exe
echo Using java: %LOCAL_JAVA%
================================
make sure you add the correct path of javax.exe while adding above logic set LOCAL_JAVA=
and start the .bat file from CMD ..that's it. It should work. It worked for me.
I started getting this error in Android Studio after I updated it to version "Electric Eel".
It happened because Android Studio has changed where they put their JRE:
it used to be C:\Program Files\Android\Android Studio\jre
but now it is C:\Program Files\Android\Android Studio\jbr
To fix:
updated my JAVA_HOME environment variable to point to the new java location (C:\Program Files\Android\Android Studio\jre)
and then restarted Android Studio, and now it is fixed.
I agree with the above explanation but if the problem still persists try setting:
CLASSPATH = C:\Program Files\Java\jdk1.7.0_06\bin