Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Creating Executable JAR file (from java class file)
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MR-D




PostPosted: 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
Sponsor
sponsor
MysticVegeta




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: Thu May 19, 2005 7:46 am   Post subject: (No subject)

no first extract and then jar them all together.
1of42




PostPosted: 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
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: