I have the following directory hierarchy :
SigarTest
src
SigarTest
.java files
bin
SigarTest
.class files
Here,SigarTest is a package name. The root folder is in the bin folder of the jdk. From there, im running the following command to create a jar file of my project -
./jar cfe temp.jar SigarTest.SigarMain SigarTest/bin/ tools.jar sigar.jar mongo-2.7.3.jar
where tools.jar, mongo-2.7.3.jar and sigar.jar are required and are in the same folder as root directory (bin folder of jdk). However, on running it, i get
ClassNotFoundException : SigarTest.SigarMain
What am i doing wrong ?
Use the
-C
dir option whichIf you execute the
jar
command in your question and list the contents of temp.jar, you will see output similar to the following:Note that having SigarTest/bin in temp.jar is incorrect. Executing temp.jar throws the
ClassNotFoundException
sinceSigarMain
is in packageSigarTest.bin.SigarTest
. Now consider the followingjar
command that uses the-C
dir option:SigarMain
is in the correct package and executing temp.jar does not throw aClassNotFoundException
.