RAVITEJA SATYAVADA
RAVITEJA SATYAVADA

Reputation: 2571

Unable to run java through bat file

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

Answers (3)

MadProgrammer
MadProgrammer

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

Suzan Cioc
Suzan Cioc

Reputation: 30147

You need no quotes in long pathnames in PATH variable.

Upvotes: 1

Jigar Joshi
Jigar Joshi

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

Related Questions