Skip to main content
gamedev.net
🔒 Locked

[java] Desktop icons and java programs

Started by Mulligan May 19, 2003 at 7:15 PM 8 replies 900+ views
Original Post
Mulligan
Mulligan
How do you make a shortcut that executes a java program? I know I''ve asked this before, but no solution seems to have worked. Actually, I lied, one did work but that was a long time ago and i deleted it because im an idiot. Thanks.
FiveFootFreak
FiveFootFreak
Well, I can only think of one solution at the moment.

You would have to make sure that the user has Java installed on his system. For Windows, there should be some entry in the registry describing the path to java.exe and javaw.exe. I can''t help you with getting this information out of the registry, but once you have it, just start up java.exe or javaw.exe with the path to your main class as argument.

I can''t help you with unix.
Mulligan
Mulligan
Im using windows, and assume that I know exactly where java.exe is and where my main class file is located.
darkWang
darkWang
make a .bat file that runs your app.
you can assign your own spiffy icons to a .bat file for looking nice.

or use another language, to create an exe that just uses the win api to execute the java vm with your program.
FiveFootFreak
FiveFootFreak
Well then your shortcut would look something like this:

Target:
C:\Programs\Java\bin\java.exe c:\myJavaGame\mainclass

Path:
C:\myJavaGame
This should work... unless your game is packed in a .jar file. I'm not very familiar with executing right out of a jar file, but you could just unpack the whole thing with WinZip (jar files are actually only zip files with some extra information) and run it normally.

[edited by - FiveFootFreak on May 19, 2003 8:35:30 PM]
FiveFootFreak
FiveFootFreak
Sorry, you have to leave out the ".class" extension. I corrected the post above.
CaptainJester
CaptainJester
FiveFootFreak is correct. If you use javaw.exe instead of java.exe, you can run it without opening a console window.

If you use a jar file, you just have to edit the manifest.mf file and add an entry like:

Main-Class: package.name.Class.name

Do not put in the .class extention and put the fully qualified package name to your class, like java.lang.String.



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
cwraith
cwraith
On windows, with a properly installed JRE, double-clicking a jar file with a proper Main-class attribute should cause it to execute automatically using javaw. Creating a shortcut to the jar works just fine.

Golthar
Golthar
Try looking at java webstart
"There is a $500 fine for detonating explosives within the confines of a city"
usser
usser
Or you could create a bootstrap, i.e creating a native executable for all operating systems where you intend to run your program. I remember seeing something on javagaming.org on how to do this yourself in Windows. If you are using Borland JBuilder (or probably any other IDE) it can create one for you.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.