Executing Jar files through bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kumar_kondapalli
Posts: 32
Joined: 08 Jul 2011 03:38

Executing Jar files through bat file

#1 Post by kumar_kondapalli » 20 Sep 2011 06:03

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

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Executing Jar files through bat file

#2 Post by dbenham » 20 Sep 2011 09:58

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

kumar_kondapalli
Posts: 32
Joined: 08 Jul 2011 03:38

Re: Executing Jar files through bat file

#3 Post by kumar_kondapalli » 20 Sep 2011 10:23

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

Post Reply