I am trying to create .jar files in java which can be used by including it in other projects. It doesn’t contain any main but only classes and methods. I am using th following command to create .jar file from command line
jar cf firstjar.jar *
I am including the jar file in my project but still the class is not available in the project.
What’s the problem in this.
My guess is that you’ve got a problem with the directory structure.
Suppose you have a class like this:
There should be
Bar.classflie in a directoryorg/foo. That structure has to be in the jar file as well – so you should go to the directory containingorgand run:(Or whatever your top-level package name is.)
If you just include the classfiles from the
foodirectory then Java’s expectations of where to find things will be invalid.