Author |
Message |
MR-D
|
Posted: Thu Dec 02, 2004 8:45 pm Post subject: Creating Executable JAR file (from java class file) |
|
|
Hi all:
Just wondering the easiest way to create an executable JAR file from a java class file. One that can be double-clicked in windows and launch the application.
I usually just write up a batch file, but this won't work due to network restrictions.
Also, the dos "jar" command-line command doesn't seem to be working (jar isn't recognized as a command).
THanks,
MRD |
|
|
|
|
|
Sponsor Sponsor
|
|
|
MysticVegeta
|
Posted: Fri May 06, 2005 5:48 pm Post subject: (No subject) |
|
|
I dont think you can launch it directly by windows. Only from the command prompt i think ->
after locating the directory
java -jar filename.jar |
|
|
|
|
|
rizzix
|
Posted: Fri May 06, 2005 10:16 pm Post subject: (No subject) |
|
|
no you can launch it directly from windows.. just double click it.. btw.. the command is something like this:
code: | cd to_compiled_class's_base_directory
jar -cfm myjar.jar . manifest_file |
just make sure in ur manifest file (an empty plain text file) you add lines similar to the following: code: | Main-Class: mypackage.my_main_class_file | where the my_main_class_file is the .class file containing the public static void main(String[]); method |
|
|
|
|
|
jskopek
|
Posted: Wed May 18, 2005 11:54 am Post subject: (No subject) |
|
|
just out of curiosity... how would you do this if you need to import drivers? for example, whenever I run my database-communicating application, I need to type
java -classpath sqlconn.jar:. LinkBrowser
is it possible to turn that into a jar file? |
|
|
|
|
|
rizzix
|
Posted: Wed May 18, 2005 2:16 pm Post subject: (No subject) |
|
|
extract the contents of that driver jar and add those contents to your jar (just exclude the META dir) |
|
|
|
|
|
jskopek
|
Posted: Wed May 18, 2005 11:19 pm Post subject: (No subject) |
|
|
huh? so you create your jar fist using the command lines shown above, then you extract the external jar file into your file? |
|
|
|
|
|
rizzix
|
Posted: Thu May 19, 2005 7:46 am Post subject: (No subject) |
|
|
no first extract and then jar them all together. |
|
|
|
|
|
1of42
|
Posted: Thu Jun 02, 2005 9:42 pm Post subject: (No subject) |
|
|
OK, I found this thread very useful. One thing though:
If I create an executable jar, it works perfectly in cmd (ie using the java -jar command). However, when I click on it thru the normal Explorer widnows, it will not in fact do the terminal stuff I need it to do(use standard input to ask a couple of things). Anybody know the reason? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|