Hi there, I am sure this is a simple (or silly) question. I have just written a GUI as a java application. It works fine if I launch it from the command prompt in Windows. Is there a way of converting the .java file to a Windows executable (.exe) file? ie. so that a user can double click on a Windows .exe file icon to launch the java app? Muchos Gracias Alan Watts
As far as I know, there are three things you can do... 1 - Have the installer (if you use an installer) create a shortcut on the desktop or in the start menu somewhere that executes the same thing your command-line instruction would be. It looks the exact same, and you don't have to mess with really compiling the code into an *.exe. Java was never intended to fully compiled, as far as I know...which is the whole point of cross-platform portability. Use a shortcut, that's why they're ther 2 - You could write a *.bat file and either put that up on the desktop (with a better icon, I'd hope) or write a *.bat file and then make a shortcut on the desktop or start menu to that *.bat file. For progs that need a more complicated startup command, then I think this is the way to go... 3 - You could go find the *.java/*.class to *.exe compiler. It is out there somewhere, but it's 100% not made by Sun...so once you make your program into an *.exe, you're out of the loop, so to speak. It can never be transferred to a Linux or Sun system accept through X Windows...and that sucks. The compiler is an open-source project, and if you're REALLY looking to make the prog into an executable, then this is the only way I know of. There is absolutely NO reason to do this, however, unless you are doing it strictly to improve execution time (which is does by eliminating the JVM overhead). From what your situation sounds like, this isn't the way to go. I am absolutely not an authority on Java or Windows... so if some local guru wants to tell me I'm wrong, go right ahead! I have messed with the *.bat files and the shortcuts porsonally, and they work just fine. The shortcut-to-*.bat is exactly the method that the jEdit editor works, by the way... http://jedit.sourceforge.net Take a look at the project and see what you think about their startup method... no *.exe here. Just *.bats and an optional shortcut. That way everything stays inside of *.jar files or *.class files and Linux, Sun, Windows, etc people can all play with it.
Don't sweat the petty stuff, just pet the sweaty stuff.
Hi Alan, yes, its possible to make an exe. Just go here: http://www.excelsior-usa.com/jet.html download the trial version and read the help file to find out how to use the utility. Seems to work pretty well for me.
You could make an exe file but if you want this to run on many platforms creating an exe will not do you any good. You can create a windows shortcut and set the target: c:\JDK1.3\bin\java.exe TestFile *you might have to specify TestFile.class and set the start in dir to where TestFile is located. I hope that works for you.
Wiser! Did you hear that guys? Wiser, I kinda LIKE that. But enough with that GREYER stuff. Really, that is no way for a gentleman to talk. . I, of course, am MUCH to young to have to worry about things like grey (snicker). Sure glad that I wasn't who you were refering to . [This message has been edited by Cindy Glass (edited June 07, 2001).]
"JavaRanch, where the deer and the Certified play" - David O'Meara