Weird PATH behaviour

I've got a problem with PATH that doesn't make much sense to me- something I've done on three different Windows 8 machines with the same result. I use Java as an example because it's a common thing to have installed. There's an PATH segment pointing to Java, and if you CMD "java" it knows what you're on about. But if you copy and paste the java.exe file file within that directory, call it "javatwo" and then CMD "javatwo", it fails. The PATH segment is pointed to the bin directory, so it should pick up everything within it.

Am I completely misunderstanding how environment variables work? I would have thought it would automatically pick it up.

The reason for my question is that I'm creating a PhoneGap app, and in order to create the android platform, I need ANT to be registered. But no matter what I do, the PATH won't pick it up as it should.


Windows Forum Admin
Staff member
Premium Supporter
Once you create your javatwo folder and place java.exe in it, you must add it to your existing path variable for it to be able to work.

For instance as a temporary test run a command prompt:
mkdir javatwo
copy javaone\java.exe javatwo
set path=%path%;C:\javatwo

Now it will be in the path, HOWEVER.. the system can be confused if there's more than one java.exe binary in the path and will choose the first one it finds I believe.

You must use the System Properties (Start, Run, "sysdm.cpl") to make the change permanent, and system wide. Example above would only work for that specific command prompt session.

Congrats on working with PhoneGap, I used to use it to develop Android apps :)

You misunderstand: all I did was copy and paste java.exe in the bin directory and rename it to javatwo.exe, then try to run "javatwo" from CMD. I didn't need to modify the PATH at all because it's in the same directory.

PhoneGap can be a pain sometimes, especially when it comes to plugins, but when creating larger apps as I do, it's nice to just do the big stuff once.

I've actually found a solution, but it's hacky. I've just copy and pasted the ANT files where i do the PhoneGap stuff. But I'd still really like to know how to do this properly for the future.

This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.