For Programmers: Free Programming Magazines  


Home > Archive > Java Help > December 2006 > How to run Java program outside of terminal?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to run Java program outside of terminal?
Lawrence

2006-12-23, 7:05 pm

Hi

I have a java program that has compiled and I have a game.java file.
This runs fine by entering manually into the terminal and running it
that way. However is there a way to execute it by just double clicking
it to open the java program?

Any help will be appreciated.

Thanks

Lawrence

Daniel Dyer

2006-12-23, 7:05 pm

On Sat, 23 Dec 2006 20:28:10 -0000, Lawrence <lawrence.hunt@gmail.com>
wrote:

> Hi
>
> I have a java program that has compiled and I have a game.java file.
> This runs fine by entering manually into the terminal and running it
> that way. However is there a way to execute it by just double clicking
> it to open the java program?


You need to create an executable JAR file.

A JAR file is a Java ARchive, much like a zip file, that bundles all of
the files that make up your program. JAR files are created with the "jar"
command line tool.

An executable JAR file is one that has a file called MANIFEST.MF in a
directory called META-INF. The manifest must include a property called
"Main-Class" that gives the fully qualified name of the class with the
main method.

Google should be able to provide plenty of examples.

Once you have created an executable JAR file, your program should run by
double-clicking on it.

Dan.

--
Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
Andrew Thompson

2006-12-26, 10:13 pm

Daniel Dyer wrote:
> On Sat, 23 Dec 2006 20:28:10 -0000, Lawrence <lawrence.hunt@gmail.com>
> wrote:

....
....[color=darkred]
> Once you have created an executable JAR file, your program should run by
> double-clicking on it.


But in addition to that, I would recommend taking it
one step further and launch the Jar using web-start.
Using web-start launch, you can suggest* to the
user that a desktop icon and menu item be created
as well. (* the user can refuse it, as they wish, and/or
change their minds later and establish an icon for it).

For web-start launch the code would need to be signed,
if it requires extended privileges. But even that is not
necessary, if it can run in a sandbox.

Andrew T.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com