erik p
erik p

Reputation: 422

How to temporarily disable the "java" command in 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.

Upvotes: 1

Views: 1122

Answers (2)

Suvajit Patra
Suvajit Patra

Reputation: 190

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.

Upvotes: 0

derpirscher
derpirscher

Reputation: 17397

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.

Upvotes: 1

Related Questions