This content has been marked as final. Show 5 replies
Like most programs, jar doesn't expand the asterisk. The shell does that. That's why
works, because the shell turns *.class into a.class b.class c.class, which is what the jar program sees.
jar cf foo.jar *.class
That doesn't work with -C, because the shell doesn't know about the -C, so it tries to expand *.class in the current directory. If I have x.class and y.class in the current directory, and a.class, b.class, and c.class in the directory where I want jar to cd to, I might try what you did:
thinking that I'd get /tmp's a, b, and c.class files. However, the shell expands that to
jar -cf foo.jar -C /tmp *.class
In short, you can't use the asterisk with the -C option (unless you happen to have files with the same names in your current directory).
jar -cf foo.jar -C /tmp x.class y.class
user485422 wrote:Yeah, but that defeats the purpose of the -C. You use -C so that you can give relative paths, and they will appear as such in the jar.
Hello. Thanks for your answer.
A friend of mine used this:
D:\Java\j2sdk1.4.2_09\bin\jar cf OfflineDocs.jar -C \Web\Tomcat\webapps\toplife\applets\help \Web\Tomcat\webapps\toplife\applets\help\avb_d\WebHelp\*.pdf
and it works!
The only difference I see is the path (in my case with a space and "").
If you do jar tvf OfflineDocs.jar, you see the full paths, starting with \Web, right? That means you could have completely skipped the -C \Web\... part.
user485422 wrote:That's rather surprising. It tried something like that earlier and I didn't get those results. I'll try to do some more messing around later and see what I come up with. It might have to do with a Windows vs. Linux vs. Cygwin difference in how that * is expanded.
The structure in the jar is:
Edited by: jverd on Apr 29, 2011 11:41 AM