I’ve got a Java installer which deploys a binary to “ProgramFiles”\myapp. I’d like to make it accessible from the command line.
Under Linux, the binary is deployed to /usr/local/bin/. Under Mac, I plan to deploy the binary to /usr/bin/.
How do I make a single command line binary accessible under Windows? Obviously I could send the binary to “WindowsDir”\System32… That would not be a clean way to do it though.
I think updating the user PATH environmental variable is a good option. How would I make it persist after reboot though?
edit:
I don’t want to hear it can’t be done as has been said in two answers so far. That’s a wrong answer and should be voted down….
C:\>echo %PATH%
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\WINDOWS\system32
C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\
Obviously Apple figured it out because QucikTime is in my path.
I don’t believe that java can actually modify environment variables. See this post about that: How do I set environment variables from Java?
The not clean answer is to use ProcessBuilder.
As the OP pointed out, calling the windows set command like this
set path=<your path>;%path%only modifies the variable in your process’s environment.A better way is to modify the registry with the reg command. The correct registry key is outlined in this Wikipedia Page: http://en.wikipedia.org/wiki/Environment_variable
Also, if you aren’t targeting Windows XP and earlier, you can try the setx command which was added in Windows Vista: http://technet.microsoft.com/en-us/library/cc755104(WS.10).aspx