I hope this is the right section for this question. I have an J2EE application already (another programmer created it) and I want to try and create a .jar file containing all the .java files. My problem comes into play that there are multiple directories of these .java files. What is the command to invoke to create a .jar file to include all .java files in sub-directories?
You can list multiple file or directory names at the end of the command line when you execute the jar command. If you specify a directory, then all subdirectories and files in that directory are included in the jar file. Let me illustrate with a simple example. Say you have the following directory hierarchy:
Then you can run the following command to create a JAR file:
I'd like to point out that I haven't actually run this example. In case it doesn't work exactly, you should just type "jar" at the command line. This will give you some simple help that should clarify what (if anything) I have done wrong in my example.
You can also list the files and directories in a text file, and list the text file's name as a parameter to the jar command. This way you don't have to retype the list every time you need to change the jar.
Note: The jar command can tell the difference between a file and a directory. If it detects that a parameter is a directory, it will recursively include the directory contents.
See Sun's jar documentation for details.
Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)