Link to home
Start Free TrialLog in
Avatar of tegz
tegz

asked on

how to create a jar file?

how do i package my program so that all my classes, images are in one file. I want to be able to double click on it and it to run on a java runtime enviroment.

I am also using jdbc connecter, do i need to put this is the package also?
Avatar of InteractiveMind
InteractiveMind
Flag of United Kingdom of Great Britain and Northern Ireland image

So, for example, at the command line, you need to move into the directory with your files, e.g:

   CD c:\directory\with\my\files

Then, run something like this:

   JAR cf MyProgram.jar "inputFile1.class" "inputFile2.class" "image1.gif"
Avatar of tegz
tegz

ASKER

im using: mysql-connector-java-3.0.11-stable-bin.jar

how do i put that in there too?
erm.. try this:

   JAR cf MyProgram.jar "inputFile1.class" "inputFile2.class" "image1.gif" "mysql-connector-java-3.0.11-stable-bin.jar"

?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use this library http://one-jar.sourceforge.net/
to supported executable jar that includes nested jars.
There is an eclipse plugin that uses this library at http://fjep.sourceforge.net/
But it will run fine with the jdbc driver jar distributed seperately. This also reduces the size of your applications jar.