1

I'm trying to compile an Android Studio Project manually (yes, I know Maven is better). Running jar -cf Package.jar * compiles both the .java files and the .class files into the jar, when I only want the .class files in there. Any way to do this?

I've tried *.class, which leads to an error.

Jared Nielsen
  • 3,669
  • 9
  • 25
  • 36
  • 1
    Is this what you're looking for? https://stackoverflow.com/questions/4591552/execute-jar-command-exclude-files – mhradek Mar 14 '18 at 23:56
  • That's the question I have, but running `*.class` yields an error, as does the accepted answer. Maybe it's because I'm developing on Windows and using `cmd.exe` – Jared Nielsen Mar 15 '18 at 00:00

1 Answers1

0

on Unix, you can use the find command to generate a list of files for the jar and include them like so:

find . -name '*class' -print0 | xargs -0 jar cvf foo.jar

Or from your existing jar, you can delete the unwanted files using zip:

find . -name '*java' -print0 | xargs -0 zip -d myjar.jar
hd1
  • 33,938
  • 5
  • 80
  • 91