Maven still doesn't run after setting environment variables - maven

here is what I have set in User Variables to run maven..
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_05
M2
%M2_HOME%\bin
M2_HOME
C:\Program Files\apache-maven-3.0.4
MAVEN_OPTS
-Xms256m -Xmx512m
PATH
%PATH%;%JAVA_HOME%\bin;%M2_HOME%\bin;
but still a mvn --version command gives my error.
I followed the steps in their own website and still getting the error.
Do you see anything wrong with what I posted above?

Have you restarted your command line window after PATH set up?

I made it work by restarting the command line tool, for doing this you have to start your CMD as administrator. Right click on CMD icon and select "Run as administrator"

On your place I would try this:
open command prompt (Start - Run - type "cmd")
and type:
cd %M2_HOME%\bin
dir
make sure you see something like "mvn.exe" or "mvn.bat"
If "cd %M2_HOME%\bin" doesn't work, the something wrong with environment. (Ex: you logged in with different user). Try
echo %M2_HOME%
in command prompt.
PS:
The better way to check environment is to type "set" in command prompt.

Related

The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program

After running...
go run main.go
I get this error
go : The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
SOLVED: Go to visual studio code (assuming this is installed) ctrl + shift + p to open command window type
Go: current GOPATH
this should give you a path create a system environment variable named GOPATH and add that path into that variable.
Make sure the system environment variables are set to:
GOPATH is set (in my case) to C:\Users[username]\go
GOROOT is set to C:\go\
IDE is Visual Studio Code.
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
write the code to the terminal and run it. Eazy way to solve the problem.
I had same issue. Then found the below solution on the book "Learning Go" of O'REILLY.
If you are on a Unix-like system using bash, add the following lines to your .profile.
(If you are using zsh, add these lines to .zshrc instead):
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
You’ll need to source $HOME/.profile to make these changes take effect in your cur‐
rent terminal window.
On Windows, run the following commands at the command prompt:
setx GOPATH %USERPROFILE%\go
setx path "%path%;%USERPROFILE%\bin"
After running these commands, you must close your current command prompt and
open a new one for these changes to take effect.
A couple of solutions:
Run refreshenv to refresh the PATH environment variable in the current terminal session.
PS C:\> refreshenv
Refreshing environment variables from the registry for powershell.exe. Please wait...
Finished
PS C:\> go version
go version go1.18.4 windows/amd64
Open a new terminal window and try again.
Restart PC and try again.
I was facing similar issues for commands installed via pip, I had to add the full path to Scripts folder to the PATH variable
C:\Users\username\.pyenv\pyenv-win\versions\3.x.y\Scripts
For go too I believe something similar is to be done.

Windows PATH variable is different if whether running CMD as admin or not

I just installed scala but I can't call it from the command line. So I dutifully checked my path through the environmental variables of the control panel and saw the scala folder present. If I type scala from cmd within that folder, it works fine.
So I tried echo %PATH% from windows cmd to see any problem. If running a normal command window, I get almost the same path except it's missing the scala path item. If I run the command line (Admin), then the echoed path matches the environment variables version. Under this admin setting, scala works fine.
There is no user path variable defined, it's only a system variable.
I've never seen this before. Why is there a difference between admin path and non-admin path? And how do I access the scala path item from the non-admin command line?
Thanks!
I just had the same problem, it was caused by the environment variables not being refreshed. A reboot would have solved it, however there is a way to refresh the environment variables without a reboot.
Open cmd prompt window
Input set PATH=C
close and restart cmd prompt window
input echo %PATH% to check
This worked for me in Windows 10.

Blank path in environment variable causing elevated command prompt to not respond

While attempting to install composer on my Windows2008r2 server, I navigated to System Properties, Environnment Variables, and Edit Path, but when I changed the path the elevated cmd prompt stopped working. So I deleted the path and left it blank. Now the cmd prompt doesnt work, and the environment variable is still blank.
Does anyone know the default path for the system variable?
c:\windows\system32;c:\windows;c:\windows\system32\wbem
Is all that is required.

Apache Tomcat 7.0.40 disappears after 1 second

I downloaded apache-tomcat-7.0.40 for Windows 8 and I followed the instructions by using the C:\apache-tomcat-7.0.40> startup.bat at my command prompt. The tomcat application appeared for 1 second and then disappeared, so I maybe the documents installation is not enough?
What should I do? While my local host is internet information service.
In command prompt run below command, you will get the root cause.
...\apache-tomcat-7.0.42\bin> catalina.bat run
In my case it was because I run catalina.bat start and this command creates new command prompt, while catalina.bat run executes in the same command prompt and doesn't close it after finishing.
Try to remove the slash at the end of CATALINA_HOME variable path.
Catalina needs JAVA_HOME to work properly. So configure path to java jre and JAVA_HOME in environment variables.
To see the error, in command prompt execute
\path\apache-tomcat-6.0.41\bin > catalina.bat run
Go to your tomcat/bin folder. Edit startup.bat file, comment out last but one line which says:
call "%EXECUTABLE%" run >..\logs\OutputFile.log 2>&1 start %CMD_LINE_ARGS% run >..\logs\OutputFile.log 2>&1
comment out using 'rem' beginning of it.
rem call "%EXECUTABLE%" run >..\logs\OutputFile.log 2>&1 start %CMD_LINE_ARGS% run >..\logs\OutputFile.log 2>&1
then Console will be remain open. if this line is commented then that means it says to close the console and write the output in some external log file.
Your problem is, most likely, wrong path of the CATALINA_HOME environment variable.
Answers above would help, but I will add one point, which would be more extensive as it may help for different kind of exceptions connected to server startup, and namely - to CATALINA_HOME.
In the late versions of Tomcat, You actually do not need to set environment variable CATALINA_HOME. If you'll have a look inside start startup.bat, the script sets it itself upon each execution.
[23-30] lines of the script in Tomcat 9:
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
So, just to be safe that your environment variable doesn't mess up with something defined by Tomcat script startup.bat (or anything else), you can either:
Remove your CATALINA_HOME environment variable entirely, as long as you start your server with startup.bat;
Correct your environment variable CATALINA_HOME path if you insist to be starting it otherwise, and make sure, nothing overrides it during run-time.

Problem to access java.exe

Hy!!
My Problem is that my terminal doesn't know the command java.
So i will solve the problem to access the java.exe directly.
Code:
'C:\Program Files\Java\jre6\bin\java.exe' -blabla
Exception:
Wrong Syntax
Please help
For your terminal to recognize command java you must put the entry C:\Program Files\Java\jre6\bin\ in your Environmental Variables in the variable called PATH.
To do so on Windows:
Right mouse click on "My Computer" and select "properties"
Go to Advanced tab
In "Advanced" click on button "Environmental Variables"
In "System Variables" edit PATH entry adding ; to the last entry
Save and restart terminal
EDIT: To run it like you want you should use " instead of '. So your command will look like:
"C:\Program Files\Java\jre6\bin\java.exe" -version
You probably need to add the path to the installed JAVA code to your enviroment PATH variable. This will allow you to just type java.exe at the command line and have it find the executable without needing the full path. Then you could type java -help to see the options available.

Resources