Sign in to follow this  
Robo-Link

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 this post


Link to post
Share on other sites
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%\bin
java -cp protoShipXWR098.class
pause

Share this post


Link to post
Share on other sites
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 this post


Link to post
Share on other sites
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 this post


Link to post
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this