Reputation:
I have updated my ant build.xml file to include a new file and a new folder. After creating the .jar I check if they exist in the jar by 'unzip\extract', and they are there.
But when executing the .jar neither the folder or the file gets extracted.
Am I missing a step?
Upvotes: 2
Views: 1930
Reputation: 5571
If you wrap your application up using One-JAR, you can specify an attribute in the Manifest file to extract files that you want (See the One-Jar-Expand manifest attribute).
As a bonus, you will also be able to wrap any dependent libraries along with your code, creating a single distributable jar.
Upvotes: 0
Reputation: 93458
Look into getResourceAsStream. It'll keep you from having to extract the files from the jar file. Unless that's your goal.
Upvotes: 4
Reputation: 24788
Are you doing something specific to extract the jar file? I ask because normally jar files are not extracted when executing them.
If you run "java -jar myJar.jar" or "java -cp myJar.jar com.example.MyMainClass" the jar files that is referenced will not be extracted. Java will load your classes and resources directly from the jar file without extracting it.
Upvotes: 1
Reputation: 426
Your application should be able to use the file directly from within the jar, no need for extracting it. Or do you mean something else?
Upvotes: 2