Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executable jar

Status
Not open for further replies.

chilster

Programmer
Joined
Apr 26, 2002
Messages
8
Location
US
Hello
I am trying to create an executable jar file. I create it successfully however when I double click on it,the 'open with' dialog opens up instead. Any ideas?
Cheers
code:

manifest-
Main-Class: MyClass
Classpath: .\MyJar.jar


command line
jar cvfm MyJar.jar manifest.mf MyClass.class



source:

import java.awt.*;
import java.awt.event.*;

public class MyClass {
public static void main(String[] args) {
Frame f = new Frame();

f.add(new Label("hi there"));
f.setSize(200,200);
f.setVisible(true);
}
}
 
I'm not quite sure what you mean here... A jar won't simply execute on a double-click. You need to call it from another java program (that imports the jar), call it from the command-line or build yourself a .bat/.cmd script that does the calling for you(through a command line). There's got to be builders that turn your jar into an .exe, but I've never done that (anyone out here?). To simply browse jar files, I use WinRAR.
 
if you are running windows, associate files with the .jar extension with the javaw executable. This should cause jar files with a main class specified to automagically execute when you double click on them.
 
If you really want to create an exe file check out this thread: Thread269-276852

However, I would have to agree with daniel and say that what you really want to do is have a bat file or a shell script, depending on what os you're running on, and launch the java app from there

-gc "I don't look busy because I did it right the first time."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top