Reputation: 1569
I write a bat script to set java path in envirnment variable. I use following command to set path -
setx PATH=%jdkDirDest%\bin;%PATH%.
setx PATH=%playDirDest%;%PATH%.
set PATH=%jdkDirDest%\bin;%PATH%.
set PATH=%playDirDest%;%PATH%.
It works fine when I am working with current session But what happen if I closed current command prompt and again open and run following command
java -version
javac etc.
It shows no java version is intall in this system
Can any one sugest me what code I use to set these environment path permanently to my matchine using bat command.
** I need bat command.
Upvotes: 3
Views: 2883
Reputation: 4712
You have to use setx without the '=', and set with it. Also use quotes for the values of the environment variables
setx PATH "%jdkDirDest%\bin;%PATH%"
setx PATH "%playDirDest%;%PATH%"
Upvotes: 3
Reputation: 1
Simply create a autoexec.bat in c:/ drive and write the following line in the file
set path=path to java home folder;
The path should not contain any white space.
save the autoexec.bat file and restart the PC.
Upvotes: 0