Set java environment variable value with bat command forever

I am writing a bat script to set java path to envirnment variable. I am using the following command to set the path -

setx PATH=%jdkDirDest%\bin;%PATH%.
setx PATH=%playDirDest%;%PATH%.
set PATH=%jdkDirDest%\bin;%PATH%.
set PATH=%playDirDest%;%PATH%.

      

It works great when I am working with the current session. But what happens if I close the current command line and reopen and run the following command

java -version
javac etc.

      

Shows that there is no java version on this system.

Can anyone tell me what code I am using to set this environment path to my match using bat command.

** I need a bat command.

Thanks to Advanced.

+3


source to share


2 answers


You need to use setx without = 'and set . Also use quotes for environment variable values



setx PATH "%jdkDirDest%\bin;%PATH%"
setx PATH "%playDirDest%;%PATH%"

      

+3


source


Just create autoexec.bat in c: / directory and write the following line in the file

set path = path to java home folder;



The path must not contain spaces.

save the autoexec.bat file and restart your computer.

0


source







All Articles