Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
> > I have programmed a java file .The program includes seven To do this you must create your own manifest file and then use this manifest file when you create your jar file. A manifest file is simply a plain text file with some special tags that the Java virtual machine knows how to work with. You can include special tags in the mainfest file that tell the Java virtual machine which file in that jar file is the executable "main" class, as well as specifying a classpath. As of RePast 1.3 all the demonstration simulations are run in this way. The following is the manifest file from bugs.jar (the heatbugs demo simulation). The Class-Path: entries should all be one line. Here the main class is uchicago.src.sim.heatBugs.HeatBugsModel and it requires the specified classpath in order to execute correctly. The class path is space delimited here, and the paths of the jar files are defined relative to the bugs.jar file. In this case two directories above the repast/demo/bugs directory in the repast/lib directory. With this manifest file in the bugs.jar archive, we execute the heatbugs simulation with java -jar bugs.jar. This has the added benefit of making the jar file executable when double click under windows. Given the above manifest file, this is directly equivalent to: (Note that as of RePast v.1.3, you no longer start models this way. repast.jar itself contains a manifest file that specifies a classpath containing all the other required jar files. So instead of the above, you can do java -cp ./bugs.jar;../../lib/repast.jar uchicago.src.sim.heatBugs.HeatBugsModel.) jar cfvm my_model.jar mymanifest my_model_dir where my_model.jar is the name of the jar file you are creating, mymanifest is the manifest file you've created and my_model_dir is the directory for your actual model. So for heatbugs this looks like: If your model is in a package (as it should be) its important to jar it from the directory above the first package directory. In the heatbugs case I would run the jar command from the directory in which the uchicago directory resided. You can inspect the contents of your jar file with jar -tf name_of_jar_file. Your manifest won't be included in the jar itself as its contents are actually copied into the MANIFEST.MF file.
Replies:
|
Sponsored Links
|