Page 1 of 1

Executing Jar files through bat file

Posted: 20 Sep 2011 06:03
by kumar_kondapalli
Hi

I have a below problem

I have installed latest java 1.7 application from sun and i want to execute the java application through bat file

Below is my bat file

@echo off
Title Java Account Manager 1.0 Startup
cd .\Initial
C:\Program Files\Java\jre7\bin\java.exe -jar CertifyAMInitial.jar"

When i execute it i am getting the below error


When I try to execute executeInitial.bat through command line it gives me the below error

"C:\Program' is not recognized as an internal or external command,operable program or batch file"


Can you please help me

Thanks,
Kumar

Re: Executing Jar files through bat file

Posted: 20 Sep 2011 09:58
by dbenham
The path to your java.exe includes a space, so you need quotes around the complete file path. You don't have quotes, so the command tokenizer treats c:\Program as the command.

It is generally a good idea to put quotes around file names to avoid this kind of problem.

I believe this line will work:

Code: Select all

"C:\Program Files\Java\jre7\bin\java.exe" -jar "CertifyAMInitial.jar"


Dave Benham

Re: Executing Jar files through bat file

Posted: 20 Sep 2011 10:23
by kumar_kondapalli
Hi Dave,

Yes you are correct. Once i Include in the quotes it works perfectly.

Thanks a lot for your help.

Just want to say one thing about this forum.

A TOUGH PROBLEM CAN BE SOLVED EAISLY BY THE EXPERTS HERE.

I LOVE THIS FORUM AND HOPE THE SAME IN FEATURE