Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set up java environment variable value using bat command permanently

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.

like image 895
Anupam Sharma Avatar asked Aug 15 '26 04:08

Anupam Sharma


1 Answers

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%"
like image 56
szhem Avatar answered Aug 16 '26 17:08

szhem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!