Stanley Mungai
Stanley Mungai

Reputation: 4150

Running a .jar File Using .bat File

HI Guys I Have A jar File Named Column Reader. I am trying to Run it using a .bat file that has the Following Script:

@echo off
java.exe -jar Column Reader.jar parameter

Can Anyone tell me why it is not Running? Because I have Managed t Run Another Jar File Named Nope.jar the same way.

Upvotes: 2

Views: 25018

Answers (2)

kentcdodds
kentcdodds

Reputation: 29021

You need to make sure that the command line knows where java.exe, and Column Reader.jar are. Also, you need to put anything that goes together in quotes, so it would be "Column Reader.jar". You may need to point directly to the jar like this:

java -jar "C:\Your\directory\Column Reader.jar" parameter

To avoid the quotes you can just make sure the path doesn't contain any spaces. Also, if you want to point to a specific java.exe file you can do:

C:\Program Files\Java\jre7\bin\java.exe -jar C:\Your\directory\column-reader.jar parameter

You don't have to be so explicit if your environment variable for java (JAVA_HOME) is set and if your .bat file is in the same directory as your .jar

Upvotes: 2

adarshr
adarshr

Reputation: 62573

This is because you have a space in the file name. Try instead with:

java.exe -jar "Column Reader.jar" parameter

Or better still, rename your JAR file to column-reader.jar. Generally JAR files are named in all lowercase, often without any spaces in the file names.

Some examples of proper JAR file names:

org.springframework.web.struts-3.1.1.RELEASE.jar
poi-ooxml-schemas.jar
slf4j-api.jar
soap.jar

Upvotes: 7

Related Questions