Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm programming in java and my question is about launching my program when I've finished it. I'm not writing this as a web program so a browser won't be executing it and I don't want people to be required to launch it from the command line, so I'm wondering how I can run it without compiling it into a native binary.
I'm writing this to be used on multiple platforms so this is why I want to keep it as bytecode and as I've been learning java all I hear is how great it is for programming e.g. Limewire, so now I'm trying to figure out how I can use it like a regular .exe.

I myself am a Java programmer, and have just discovered how to do this myself. You need to make an executable .jar file. Here is how this is done.
1. Make a text document named "Manifest.txt" and type the following:
Main-Class:"YourClassName" (Do not add ".class")
then make sure you press enter after the end of the line. The manifest needs to have 1 empty line at the end of it.
2. Make a batch file named "Jarpackager.bat" and have this for the body:
jar cmf Manifest.txt YourProgram.jar *.class
(You can add more file types here to include in your program i.e. pictures and such)3. Now find the folder with jar.exe, should be in your JDK/bin folder. Place your class file, Manifest.txt, and Jarpackager.bat into the directory and run Jarpackager.bat.
Keep in mind all of the file names are case sensitive, and the empty line at the end of the manifest.txt file is a must. Good luck with it, and if you need more help i'll be around.

So this should automatically be associated with the java VRE and it will run the program correctly? What happens if someone doesn't have Jar files associated with the java VRE? For example my zipping utility associates with jar files, which means if I double click a jar file it won't be launched.

Oh I also haven't gotten this to work right yet. I tried this program:
http://java.sun.com/docs/books/tutorial/uiswing/14start/compile.htmlto test it.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |