smwikipedia
smwikipedia

Reputation: 64205

Use jar to create a jar file over a folder

I see someone is using the following command to create a jar file from a folder containing many Java packages (i.e. sub folders)

jar cvf program.jar -C folder1/folder2/folder3 .

It seems the command won't work without the last .. And I tried to use * instead. Also works.

So what does the last . or * mean?

Upvotes: 0

Views: 80

Answers (1)

rafalopez79
rafalopez79

Reputation: 2076

See jar documentation

-C option changes to the specified directory and adds the next file to the jar.

Example:

jar cf ImageAudio.jar -C images . -C audio .

The -C images part of this command directs the Jar tool to go to the images directory, and the . following -C images directs the Jar tool to archive all the contents of that directory. The -C audio . part of the command then does the same with the audio directory.

So, in your example, you will add to the jar the content of folder1/folder2/folder3 directory.

Upvotes: 1

Related Questions