# Help with a .bat?

## Recommended Posts

Okay, so I am trying to get a bat file to run my java game since I can't get it into a working .jar, and I am looking for other ways to release it anyway. But I have no idea how a .bat works. So far, I got this: set PATH=%PATH%;%JAVA_HOME%\bin java -cp protoShipXWR098.class It spits an error, but I can't read it because the cmd window disapears too fast. Anyone know whats going on? or how I can pause the window?

##### Share on other sites
Jaywalk    250
I don't know the answer, but I can offer a suggestion. Put a pause in the .bat file so that you can see the error message, and then tell us what the error is, so we can give you a more educated answer.
set PATH=%PATH%;%JAVA_HOME%\binjava -cp protoShipXWR098.classpause

##### Share on other sites
Zahlman    1682
The -cp flag is used to define the classpath - that is to say, where Java will look for the named source file. The next word after '-cp' will be used as that path. So right now, it's trying to use your .class file name as a path name, and doesn't have a name for the class to run.

Try
java -cp . protoShipXWR098.class
. Note the dot; this indicates to use the current folder for the class path. (And then, of course, the .class name, not being preceded by any flag, is interpreted as the main class to run.)

##### Share on other sites
AndiDog    145
The java.exe wants the class name, not the file name of it, so you will have to call "java protoShipXWR098", not "java protoShipXWR098.class" !

##### Share on other sites
Zahlman    1682
Er, yes, that too.

##### Share on other sites
Okay, my friend said she got just a "press any key to continue" screen after running this as run.bat
set PATH=%PATH%;%JAVA_HOME%\bin
java -cp protoship
pause

Here's my games beta with that file. If someone can use it to figure out whats wrong, please do so.

http://rapidshare.com/files/141184493/ps2a3.zip.html

##### Share on other sites
snisarenko    526
You passed a "-cp" option which means it expects the CLASSPATH to follow that option. In your case it interprets "protoship" as classpath and then doesn't run anything. Here's what it should be

set PATH=%PATH%;%JAVA_HOME%\bin
java protoship
pause

Also class names are case sensitive. So make sure you type the name of the class "protoship" as it appears in your code.