Java jar with package
First, create a txt file called manifest.txt in the same folder as the .class file .
Then type Main-Class: ExhaustiveSearch
1)note that myClass not myClass
2)note that after myClass there is a new line
3)note if this class, say ExhaustiveSearch is in a package, then the manifest.txt must be in the package folder, then type in Main-Class: exhaustive/ExhaustiveSearch
Second, jar class file and manifest file with
jar -cvmf manifest.txt app1.jar *.class
or jar -cvmf manifest.txt app1.jar ExhaustiveSearch.class
1)note that if ExhaustiveSearch.class is in a package(not mean folder, although in the file system a package is represent as a folder), then you must jar them outside the package(because then you can jar the package together).
2) for example in path E:\java_workspace\Knapsack\bin\exhaustive\ExhaustiveSearch.class
when you want to jar this, you have to create manifest.txt in folder bin.
Then you type jar -cvmf manifest.txt app1.jar exhaustive/ExhaustiveSearch.class
(note here you type exhaustive/ExhaustiveSearch.class
but if you want to run the class regularly then you need only type" java ExhaustiveSearch", because the jvm will figure out the ExhaustiveSearch.class is actuall in the package exhaustive.)
Then type Main-Class: ExhaustiveSearch
1)note that myClass not myClass
2)note that after myClass there is a new line
3)note if this class, say ExhaustiveSearch is in a package, then the manifest.txt must be in the package folder, then type in Main-Class: exhaustive/ExhaustiveSearch
Second, jar class file and manifest file with
jar -cvmf manifest.txt app1.jar *.class
or jar -cvmf manifest.txt app1.jar ExhaustiveSearch.class
1)note that if ExhaustiveSearch.class is in a package(not mean folder, although in the file system a package is represent as a folder), then you must jar them outside the package(because then you can jar the package together).
2) for example in path E:\java_workspace\Knapsack\bin\exhaustive\ExhaustiveSearch.class
when you want to jar this, you have to create manifest.txt in folder bin.
Then you type jar -cvmf manifest.txt app1.jar exhaustive/ExhaustiveSearch.class
(note here you type exhaustive/ExhaustiveSearch.class
but if you want to run the class regularly then you need only type" java ExhaustiveSearch", because the jvm will figure out the ExhaustiveSearch.class is actuall in the package exhaustive.)
评论
发表评论