How to temporarily disable the "java" command in cmd - cmd

I have a situation where I need to test a program with and without Java "installed". Instead of uninstalling and reinstalling for each test, I figured it would be ideal if I could simply disable the "java" command from working in cmd as this is the way the program determines if Java is installed. Is there an easy way to do this? I have tried removing any mentions of Java from the Environment variables (I'm on Windows 10 Education), but this does not seem to have had any effect. I am okay with hacky solutions as I just need this for my own quick tests on my machine.

Check the location of the java executabe with
c:\> where java
This may return multiple instances of java.exe in different directories of your PATH. Remove all returned directories from the PATH and restart your cmd.exe, because cmd will pick up changes in the environment variables only after it is restarted.

Remove all the paths of java from the environment variables(from user variables and System variables) then start cmd and type java, it should be unrecognised.

Related

Maven isn't installing properly

I've tried everything I could find on this topic, yet I'm not able to install Maven.
I'm at the following point:
I have java installed
I unzipped the files from the apache website
I have set up environment variables and added requirement parameters to the path (had to use the escape character in the path, because of the space in Program Files folder name: C:\Program^ Files\apache-maven-3.6.3)
what could be the problem?
cmd
From the attached image all requirements are OK. Try one of those two solutions:
Close the CMD window and reopen it (if you didn't this already).
Restart your computer in in order to apply the environment variables you've just added.

Detect commandline application from CMD without messing with PATH variable or System32/SysWow64 dir

Scenario
I would like to install an x86 CommandLine application on a folder outside C:\Windows\System32 or C:\Windows\Syswow64 and still be able to access my app under CMD without adding my application's path inside the PATH environment variable.
Question
Is this possible to do? Maybe touching a needed registry keys?
Note: I know how to add my application into PATH variable/regvalue or how to access my application from CMD putting the required .exe in the System32/SysWow64 folder. This question is only to learn alternatives, it's not to solve issues with PATH or System dirs.
Code
I've tried this suggested approach from a comment of #Sertac Akyuz in this answer, I have stored MyApp.exe on C:\ root directory, but I can't detect the application just putting MyApp.exe under the CMD.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
#="C:\\MyApp.exe"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
#="C:\\MyApp.exe"
[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
#="C:\\MyApp.exe"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
#="C:\\MyApp.exe"
App Paths registry settings - used by Windows Explorer, to locate programs when you type program name in "Run..." box, and so on. These settings are not affecting cmd.exe behavior.
The only way to set up cmd.exe paths for searching applications is changing PATH environment variable. You can start cmd.exe from your own .bat/.cmd where you set up all required variables for current session, without changing it globally.

Maven 3.0.5 installed in Windows 7 but not able to run through command prompt

As per suggestions given in this site i have added the required variables and values as below too but no response
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25
M2=%M2_HOME%\bin
M2_HOME=C:\Program Files\apache-maven-3.0.5-bin\apache-maven-3.0.5\bin
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%M2_Home%\bin
Please help me
Your path configuration has a M2_Home instead of M2_HOME. It should be all uppercase
%M2_HOME%
Also notice, you are specifying bin twice, should
M2_HOME=C:\Program Files\apache-maven-3.0.5-bin\apache-maven-3.0.5
I had same situation multiple times, i.e. configured M2_HOME as user env variable and added it to PATH (system env variable), i.e.
PATH=%M2_HOME%\bin; ...
However sometimes (randomly) Windows don't resolve variable in path, run "echo %PATH%" in your console. In my case I can still see %M2_HOME% there instead of resolved path to maven installation directory. It seems to be a bug in Windows itself, which is present in WinXP and Win7 at least.
I have resolved it as follows:
Open env variables, change M2_HOME (user one) to correct value. Press OK to save and close window
Open env variables again, now open PATH (system one) variable details, make sure M2_HOME is there and press OK, i.e. just save without any modification.
Now, open command line and check "echo %PATH%" - there should be resolved path. Confirm by running "mvn --version".
I know it really sounds like a black magic, but it should work...

Apache Maven installation in windows 8

I followed steps mentioned in this link http://maven.apache.org/download.cgi
Whenever I type mvn --version in cmd.
I got 'mvn' is not recognized as an internal or external command, operable program or batch file.
But when I opened cmd with "Run as a administrator" it worked.
OS: windows 8
How can I run mvn for any user on windows 8.
Try setting the environment variable M2 as System variable instead of User variable.
I used Rapid Environment Editor, started as an Administrator, and put these variables into my System path, and this problem went away.
For some reason, when I added the the JDK, JRE, and Maven bin folders to my Path through the Windows utility, it didn't work. Rapid Environment Editor told me that the variables were not valid or I did not have access to them. Windows 8 seems to be really picky about administrator rights and I guess they didn't think that through very well.
Just be sure to start Rapid Environment Editor as an administrator, and re-open your command windows when you save your changes.
I had to move the installation directory of Maven into C:\Users*your_username*, so that Maven no longer required admin permissions. The PATH variables started working after that.
Set the MAVEN/M2 and MAVEN_HOME/M2_HOME variables in the environment variables in windows 8, this will solve the problem.
I'm using chinese version so that i'm not sure what's these word in english version.
click right button on "My computer"
click last item on list
click "Advanced system setting" at left side
"Evironment Variable"
append maven's bin directory into system's environment variables path
after all, try linux
The simplest way is:
Add maven directory to the path in systems variable.
don't add anything in user variable and no need to add any variable.
faced the same problem; The bins or files from path for M2_home and Java_home need to be found in a directory where the user has full control permission. Change the security permission settings of the user through the administrator by right click on the order, go to properties->security tab and check the Full control box for "authenticated user" and "user".

‘ant’ is not recognized as an internal or external command

I have the same issue as this user: ant - not recognized as an internal
however unfortunately none of the solutions have worked for me in that post or any other. I've also looked at other commands not recognized and specifically adding a path variable. The procedure I am using is as follows:
Extract to a desired installation directory, e.g. C:\apache-ant
Create an ANT_HOME environment variable`
Open System Properties -> Advanced -> Environment Variables
Create a new system variable
Variable name: ANT_HOME
Variable value: C:\apache-ant
Add %ANT_HOME%\bin directory to the PATH system variable
Open System Properties -> Advanced -> Environment Variables
Under system variables, select PATH and append ;%ANT_HOME%\bin
e.g. %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%ANT_HOME%\bin
Verify that ANT is installed.
Open a new command window and type:
C:\>ant -v`
In my case the Variable value is C:\apache-ant\apache-ant-1.8.2.
My exact path variable is %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin;%ANT_HOME%\bin which doesn't have any spaces between semicolons.
However testing the ant installation does not work, the picture below is what I'm experiencing:
I have tried restarting on numerous occasions to no avail. I have run out of ideas, so if anyone has any any information would be helpful. Thanks!
EDIT
Posted results of dir:
ANT_HOME is not being resolved. Change %ANT_HOME%\bin in the Path system environment variable to c:\apache-ant\apache-ant-1.8.2\bin.
I had a similar issue, but the reason that %ANT_HOME% wasn't resolving is that I had added it as a USER variable, not a SYSTEM one. Sorted now, thanks to this post.
create a script including the following;
(replace the ant and jdk paths with whatever is correct for your machine)
set PATH=%BASEPATH%
set ANT_HOME=c:\tools\apache-ant-1.9-bin
set JAVA_HOME=c:\tools\jdk7x64
set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH%
run it in shell.
When Environment variables are changed log off and log in again so that it will be applied.
I downloaded ant (http://ant.apache.org/bindownload.cgi), unzipped to my C drive, and used the windows 'doskey' command:
doskey ant=C:\apache-ant-1.9.6\bin\ant.bat $*
this will work as long as you use the same command console, to make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
Please follow these steps
In User Variables
Set VARIABLE NAME=ANT_HOME VARIABLE PATH =C:\Program Files\apache-ant-1.9.7
2.Edit User Variable PATH = %ANT_HOME%\bin
Go to System Variables
Set Path =%ANT_HOME%\bin
Had the same problem. The solution is to add a \ at the end of %ANT_HOME%\bin so it became %ANT_HOME%\bin\
Worked for me. (Should be system var)
even with the environment variables set, I found that ant -version does not work in scripts. Try call ant -version
Need to see whether you got ant folder moved by mistake or unknowingly.
It is set in environment variables.I resolved this once as mentioned below.
I removed ant folder by mistake and placed in another folder.I went to command prompt and typed "path". It has given me path as "F:\apache-ant-1.9.4\".
So I moved the ant back to F drive and it resolved the issue.
If none above helped anyone...My issue was that I was trying to use ant -version on a cmd prompt that I had already opened before I added apache-ant to the path.
As the cmd prompt was using the PATH it had when it was opened and not the new one (that had apache-ant) it wasn't finding it.
Opening a new cmd and running ant -version showed me I actually did have it installed correctly.
I got same problem , what I did for fix :
Open system environment variable
Click on environment variable
in user varaible -> edit path and then add C:\FolderWhereYouInstalled\ant\ant_1.8.4\bin
Click ok
Open cmd and type : ant -version
thanks, might help someone :)

Resources