How to run a JAR file through an icon on Java Desktop Application Using Swing?
I want to execute a jar file (BORG Calendar) from an icon 开发者_JAVA百科in a desktop application using java swing (JinternalFrame, JDesktoppane,...) But I dont know how?
Java Web Start can suggest desktop icons & menu items for a application. I would recommend doing both, since from memory some OS' will disallow one or the other.
Alternately, JWS can leave the choice to the user, with the assistance of the javax.jnlp.IntegrationService.
JWS is available for platforms that run Java, and is supported by Oracle.
If you want to run your app using an icon in the desktop you have to export it as an executable jar file.
Here a tutorial how can you do it from the command line: http://viralpatel.net/blogs/2008/12/create-jar-file-in-java-eclipse.html
I suppose that you use an IDE for your programming, so you should have somewhere the option export as executable jar.
This is how i do it in eclipse:
Then find the jar file with the play icon.
I think that is all you need. You can optionally click on next and configure some more options. Note: Maybe your app uses external libraries or images that also should be added, dont forget about them.
you need to export your program as jar , then use a program like Lunch4j if you want to make a shortcut to your jar .
精彩评论