Jump to content
xisto Community
iGuest

JAR problems Java Run Without Command Line Or Jde

Recommended Posts

JAR problemsJava Run Without Command Line Or Jde

In my AP Computer Programming class, we were required to program a game in Java. I made a game called TechnoFrogger, which is like normal Frogger in everyway, but there is a mode that can make everything change colors, have the window move around the screen, and of course, play techno music.

I've use Eclipse's export as JAR file several times, to try and get the file to work without having to run it in Eclipse SDK. I've encountered some problems.

1. I can't get the file to run off of a double click. I've looked around online and heard of using command prompt and what not to get the file to work like so, and .Bat files and whatnot, but I haven't an idea what to do with that. Or what a .Bat file even is =[

2. I use some .Dat files in my game, which keep track of the highscores. If I delete these files, the game will run off of a double click.

I'd like my game to work with the highscores, but this is all very new to me and my teacher didn't really know what to do with JAR files anyways. Any help would be appreciated. Thank you.

-question by Matt

Share this post


Link to post
Share on other sites

Hi!First off, let me explain that JAR files are simply ZIP archive files containing a manifest (i.e. information about the contents... think of it as metadata) and Java class files and other resources. To start a JAR archive, you can either run a Java class file within the archive within a command-line environment or create a batch file. A batch file is essentially just a file containing the commands that you type within the command-line environment saved in a file ending with a .bat file extension. You could also use third party utilities to create a launcher for your application, which essentially packages it as an executable file ending. For Windows, this would mean you will have a .EXE file. Third party utilities can do a lot for you, right from packaging the Java Runtime Environment into the setup to having the setup download the Java Runtime Environment off the Java section of the Sun Microsystems website. They can create shortcuts in the Program Files Start menu and on the desktop. It essentially makes your application look like a traditional Windows application.There's a lot that you can do with batch files, such as displaying a menu for the user to select a set of commands, or to enable a user to type command-line parameters when executing the batch file via the command-line environment but most people today simply use it to execute pre-defined command-line statements sequentially. I remember doing quite a bit of stuff in the MS DOS age with batch files instead of having to code it into C or C++ simply because I didn't have to re-compile if I made a change in the batch file.I don't really know what you mean when you say that the game will run off a double click when you delete the .dat files. Doesn't the game normally run when you double-click on the batch file? Or do you simply mean you want the high scores to be cleared when you delete the .dat file? That question isn't really very clear so it would help if you could elucidate more upon how you would like your program to behave on deleting the .dat file containing the high scores.When you give the JAR file to your teacher as an assignment deliverable, you would also want to provide instructions, such as the command-line to type to start up the program. What he/she needs is simple the name of the class containing the main method (program entry-point) to begin execution. I doubt he/she would be capable as a teacher if he/she didn't know how to execute a JAR file, so you simply need to provide the name of the main class along with the namespace.Regards,Nitin ReddyPS: Rename a JAR file to a ZIP file and double-click on it. You'll see that there is a lot less to JAR files than you think!

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

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.