3

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.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Anupam Sharma
  • 1,529
  • 1
  • 14
  • 33

2 Answers2

3

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%"
szhem
  • 4,672
  • 2
  • 18
  • 30
0

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.

  • I have created a file and save that to c direcotry but after restart my pc I type path command in command prompt but it is not showing path that I set in file :( – Anupam Sharma Sep 25 '14 at 05:04