Reputation: 2571
I set my environment variables correct, and while running Java <classname>
it is running fine.
But when running the same through a bat file, I'm getting errors like
java is not recognized as internal or external command or bat file
.
I tried displaying the path and classpath, but everything is fine there. What am I doing wrong?
Here is my piece of code:
cd\
cd C:\myproject
set PATH="C:\Program Files\Java\jdk1.7.0_51\bin;"%PATH%
set CLASSPATH="C:\myproject\sqljdbc4.jar;C:\myproject\jxl-2.6.12.jar"
java InsertRecords %1 %2
pause
Upvotes: 0
Views: 1091
Reputation: 347332
I think the problem is with how you are setting the path variable...take a look at this...
"C:\Program Files\Java\jdk1.7.0_51\bin;"
^---This doesn't look right
Try using something more like...
set PATH="C:\Program Files\Java\jdk1.7.0_51\bin";%PATH%
^--- Note the change here...
Upvotes: 1
Reputation: 240996
java executable isn't covered in PATH, add it to path
change it to
set PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_51\bin\
Upvotes: 2