简体   繁体   中英

Eclipse ANT Build.xml create JAR is showing corrupted file

I've been searching a lot about this and was not able to find any solution.

Basically I'm just trying to Create a jar from my project. Then use that for deployment.

Here's my code in build.xml

<?xml version="1.0" ?>
<!-- Configuration of the Ant build system to generate a Jar file --> 
<project name="TestMain" default="CreateJar">
  <target name="CreateJar" description="Create Jar file">
        <jar jarfile="SamCommon.jar" basedir="bin"/>
  </target>
</project>

This is working okay and the jar file is visible and can be opened in the root directory of the project.

But what I want is to create/generate the jar on a different location.

So I set this configuration but whenever it outputs the file in that destination it shows as corrupt file. Please advise

Screenshots:

http://i.stack.imgur.com/Q4p3E.jpg

http://i.stack.imgur.com/uuhm3.jpg

Try this: <jar destfile="your_directory/SamCommon.jar" basedir="bin" />

Error is occurring because "Standard input and output" option in "Build Options" define where your "sysouts" will be written, not your jar file. If you open generated "SamCommon.jar" in a text editor, certainly you will see only text content generated by ANT execution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM