How to make executable java file? (Executable Jar using Eclipse)
Post date: Mar 21, 2011 11:51:11 AM
It sounds like you want to use the "Export JAR File" wizard instead of the "Export Runnable JAR File" wizard. When exporting a runnable jar file, Eclipse attempts to pack everything needed to run the application into a single archive. On the other hand, the "Export JAR File" wizard gives you more control over what is packaged in the archive. You can still create a runnable jar file, but you must make sure to include BouncyCastle.jar on the classpath when you execute the jar. Here are step-by-step instructions:
Click "File | Export". The Export dialog pops up.
Expand the "Java" folder and select "JAR file" (not "Runnable JAR file"). Click Next. On the JAR file specification page, choose the classes you want included in the jar file, and specify the name of the JAR file to create. Click Next.
On the JAR Packaging Options page, select options appropriate for you. The defaults are probably fine. Click Next.
On the JAR Manifest Specification, make sure to select the "Main class" for your jar file. This is the class that will be executed when you execute the jar file. If you leave this blank, the jar file will not be runnable. Click Finish to create the jar file.
You should be able to execute the jar file by executing "java -jar myjarfile.jar -classpath BouncyCastle.jar" from a command line.