0

I am having issues with my PATH variable. I have installed JBOSS-AS in the version 7.1.1 Final and set the environment variable (hope it's the correct term, since my OS is in German) JBOSS_HOME to the path I installed it to: C:\Program Files\jboss-as-7.1.1.Final.

Then I added %JBOSS_HOME%\bin; to the PATH system variable.
After restarting the cmd I could call everything in that bin folder (mostly *.bat-files) by it's name without naming the full path leading to it. So that went well. But then I rebooted my PC and it didn't work anymore. I had to go to the environment variables, select PATH, edit... and klick OK (without changing anything) to make the cmd recognize it again.
Odd thing is, that echo %JBOSS_HOME% returns the correct path and echo %PATH% returns:

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd;%JAVA_HOME%\bin;%M2_HOME%\bin;%JBOSS_HOME%\bin;C:\Program Files (x86)\Notepad++;C:\Users\Markus\AppData\Roaming\npm

So %JBOSS_HOME%\bin is still in there...

Any Idea what is happening here?

Markus Rohlof
  • 121
  • 1
  • 8
  • 1
    How do you set the variables? Are you using the command line or the GUI interface? – MichaelS Oct 14 '14 at 11:19
  • Do you have set environment variable **JBOSS_HOME** also in system environment table? If you press and hold Windows key and additionally press key Pause, i.e. Win+Pause, system control panel window opens (all Windows OS since Win95). There is **Advanced system settings** on left side. Clicking on this link a dialog window opens with the tab **Advanced**. There is the button **Environment Variables**. Click on it and you see 2 environment variable lists - one for your user account only and another one for the system (= all accounts). Make sure to make both modifications in same list. – Mofi Oct 14 '14 at 12:50
  • I used the GUI Interface provided by Windows (the one you end up in when following Mofis instructions) and added both the JBOSS_HOME and the new entry in PATH to the system variables. I have another PATH variable in the user environment variables, though. It's the "C:\Users\Markus\AppData\Roaming\npm" you can see at the end of the listing above. How would I set the variables via command line anyway? Maybe I'll just try that. //Edit: nevermind, found out how you can do that here: [Adding directory to PATH Environment Variable in Windows](http://stackoverflow.com/a/9546345/4134934) – Markus Rohlof Oct 14 '14 at 13:18

1 Answers1

0

Thanks to @MichaelS I at least now know a workaround for that problem:

It seems to work fine when you add the environment variables via command line or batch file, but I don't know why, since the environment variables GUI looks the same as before, when I added them manually.

Here's the content of the batch file (for command line see below) I used:

setx JBOSS_HOME "C:\Program Files\jboss-as-7.1.1.Final" /M
setx PATH_OLD "%PATH%" /M
setx PATH "%PATH%%%JBOSS_HOME%%\bin;" /M

setx sets (and overrides!) environment variables.
The multiple %-signs are to escape the %JBOSS_HOME%-variable so it does not end up as "C:\Program Files\jboss-as-7.1.1.Final".
%% is going to be a single %, while a single % will make the variable expand to it's content. So in this case %PATH% will become the content of the %PATH% variable while %%JBOSS_HOME%% will simply become %JBOSS_HOME%.
/M makes the environment variables system-wide and not only for your user. For this you will need to open the file with admin rights, otherwise it won't work.

If you're not using a batch file but the command line directly, the escape character is ^, I think, but I did not try that out. So the commands would be :

setx JBOSS_HOME "C:\Program Files\jboss-as-7.1.1.Final" /M
setx PATH_OLD "%PATH%" /M
setx PATH "%PATH%^%JBOSS_HOME^%\bin;" /M

Also, I had to rename the user environment variable named PATH beforehand (and undo it afterwards), because %PATH% concatenates the system und user environment variables, which would add the content of the user variable to the system variable.

I only set PATH_OLD in case something goes wrong, I believe it's recommended but not necessary for what I wanted to do.

Markus Rohlof
  • 121
  • 1
  • 8