Compiling a jar or zip file with Ant

Hi,
I am using Java 1.4.2 and Ant 1.6.1
I am trying to use the javac task to compile a jar file and a zip file directly (i.e. they contain compressed .java files) instead of uncompressing them first and then compiling them. Is it supported in Ant?
i.e.
<target name="compileinit">
<mkdir dir="${compile.outdir}"/>
<!--Compile Java source files in a jar file-->
<javac destdir="${compile.outdir}" debug="on">
<classpath refid="classpath"/>
<src refid="srcpath"/>
<include name="jarfile.jar"/>
<include name="zipfile.zip"/>
</javac>
</target>
Thanks!

It's not clear what you are asking. Maybe this will help
http://www.cfdev.com/code_samples/code.cfm/CodeID/83/Java/Simple_Ant_build_xml_Build_Task

Similar Messages

  • Jar (or Zip) file with problems in accents, special characters

    Hi! I've a servlet that creates a jar (or zip) file and then send it. My problem is that when I create an entry in which the filename has special characters such as accents, when I unjar or unzip de file, it brings a lot of garbage characters. For example, the nex entry:
    Ex�menes.doc
    when unzipped is:
    Ex?�menes.doc
    I've tried a lot of things:
    -Setting the locale to ES, MX
    -Replacing all the letters with special characters with its unicode (like s.replace('�','\u00E1')
    -Trying to convert it to UTF8 (new String(path.getBytes(),"UTF8") )
    -Replacing the file separator char (according to a workaround that I found in the bug database)
    But nothing of this worked, alone or together. I've read that this is (or was) a bug in the API, but don't know if a solution has been found.
    Any help will be greatly appreciated!

    It's not clear what you are asking. Maybe this will help
    http://www.cfdev.com/code_samples/code.cfm/CodeID/83/Java/Simple_Ant_build_xml_Build_Task

  • Classpath to .jars inside .zip files

    I had post something similar to this but this time it's another idea (and another problem) - so, this is not cross-posting.
    I have this .zip file with 25 .jar files, I want to use it in my Manifest file, but it seems that when the classes are in the .jars and the .jars are in a zip file they are not reached by the Classloader.
    #  Archive Libs.zip*
    commons-collections-3.1.jar
    commons-digester.jar
    commons-lang-2.0.jar
    commons-logging-1.0.3.jar
    commons-logging.jar
    commons-logging-api.jar
    commons-net-1.4.1.jar
    firebirdsql-full.jar
    formsrt.jar
    itext-1.3.1.jar
    jasperreports-1.3.1.jar
    jaybird-2.1.1.jar
    jaybird-full-2.1.1.jar
    jcommon-1.0.0-rc1.jar
    jdt-compiler.jar
    jfreechart-1.0.0-rc1.jar
    Lib.jar
    log4j-1.2.14.jar
    looks-1.3.1.jar
    mail.jar
    pop3.jar
    substance-lite.jar
    swingx-0.8.0.jar
    activation.jar
    commons-beanutils.jar12670124 10779634 25
    The file MANIFEST.MF
    Manifest-Version: 1.0
    Specification-Version: 3
    Implementation-Version: 0 2007
    Implementation-Title: SikGraf(Standard)
    Specification-Vendor: Kooky
    Created-By: Kooky
    Main-Class: com.sikgraf.main.Main
    SplashScreen-Image: com/sikgraf/imagens/siggraf.jpg
    Class-Path: . \SikGrafStandard.jar \C:/Kooky/SigGraf/Libs.zip[/code]
    Is is possible to do that? (.jars inside a zip) Or am I dreaming here?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You would have to write your own custom classloader to do this, which is what http://one-jar.sourceforge.net/ tries to do.

  • Decompress ZIP file with Password

    Hi all,
    Does anybody know how to decompress a ZIP file with password protection?
    I have a decompress code, but I don't know how to insert the pass.
    Any solution?
    Regards

    I'm running out of suggestions over here.
    Your exact command line yields this result:
    zip warning: name not matched: in.txt
    zip error: Nothing to do! (out.zip)
    Well, it should, as I don't have an in.txt. Handing it an existing file, I get this:
    zip -P pass out.zip result.txt
      adding: result.txt (deflated 7%)
    .. and opening in the Finder correctly prompts me:
    so there must be something wrong with your system.
    Very Long Shot: What version do you get when you type this? (I can't imagine this is the actual problem, but you never know.)
    zip --version
    Mine is
    Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
    This is Zip 3.0 (July 5th 2008), by Info-ZIP.
    Currently maintained by E. Gordon.  Please send bug reports to
    the authors using the web page at www.info-zip.org; see README for details.
    Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,
    as of above date; see http://www.info-zip.org/ for other sites.
    Compiled with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) for Unix (Mac OS X) on May 25 2011.

  • I am trying to organize a zip file with a bunch of links and files. But when I drag an image file to a folder, it always "Snaps to grid" instead of just landing where I put it.

    I am trying to organize a zip file with a bunch of links and files. But when I drag an image file to a folder, it always "Snaps to grid" instead of just landing where I put it. All of the files are going into the same zip file but I want them visually in the space that I put them and not at the bottom of the snap to grid folder location they are looking like.  I am trying to  drag and drop files in groups so that I can group them for now, but image files always do their own "sort by" when I drag them from my web pages. Links don't do it though.  I tried resetting the folder, and deleting the DS files. No luck.

    You keep asking variants on this same question. You've had replies in all your other threads. If you can't find them, go here and click where it says Activity:
    Thomas Cannon Jr.

  • Cannot extract Zip file with Winzip after zipping with java.util.zip

    Hi all,
    I write a class for zip and unzip the text files together which can be zip and unzip successfully with Java platform. However, I cannot extract the zip file with Winzip or even WinRAR after zipping with Java platform.
    Please help to comment, thanks~
    Below is the code:
    =====================================================================
    package myapp.util;
    import java.io.* ;
    import java.util.TreeMap ;
    import java.util.zip.* ;
    import myapp.exception.UserException ;
    public class CompressionUtil {
      public CompressionUtil() {
        super() ;
      public void createZip(String zipName, String fileName)
          throws ZipException, FileNotFoundException, IOException, UserException {
        FileOutputStream fos = null ;
        BufferedOutputStream bos = null ;
        ZipOutputStream zos = null ;
        File file = null ;
        try {
          file = new File(zipName) ; //new zip file
          if (file.isDirectory()) //check if it is a directory
         throw new UserException("Invalid zip file ["+zipName+"]") ;
          if (file.exists() && !file.canWrite()) //check if it is readonly
         throw new UserException("Zip file is ReadOnly ["+zipName+"]") ;
          if (file.exists()) //overwrite the existing file
         file.delete();
          file.createNewFile();
          //instantiate the ZipOutputStream
          fos = new FileOutputStream(file) ;
          bos = new BufferedOutputStream(fos) ;
          zos = new ZipOutputStream(bos) ;
          this.writeZipFileEntry(zos, fileName); //call to write the file into the zip
          zos.finish() ;
        catch (ZipException ze) {
          throw ze ;
        catch (FileNotFoundException fnfe) {
          throw fnfe ;
        catch (IOException ioe) {
          throw ioe ;
        catch (UserException ue) {
          throw ue ;
        finally {
          //close all the stream and file
          if (fos != null)
         fos.close() ;
          if (bos != null)
         bos.close();
          if (zos != null)
         zos.close();
          if (file != null)
         file = null ;
        }//end of try-catch-finally
      private void writeZipFileEntry(ZipOutputStream zos, String fileName)
          throws ZipException, FileNotFoundException, IOException, UserException {
        BufferedInputStream bis = null ;
        File file = null ;
        ZipEntry zentry = null ;
        byte[] bArray = null ;
        try {
          file = new File(fileName) ; //instantiate the file
          if (!file.exists()) //check if the file is not exist
         throw new UserException("No such file ["+fileName+"]") ;
          if (file.isDirectory()) //check if the file is a directory
         throw new UserException("Invalid file ["+fileName+"]") ;
          //instantiate the BufferedInputStream
          bis = new BufferedInputStream(new FileInputStream(file)) ;
          //Get the content of the file and put into the byte[]
          int size = (int) file.length();
          if (size == -1)
         throw new UserException("Cannot determine the file size [" +fileName + "]");
          bArray = new byte[(int) size];
          int rb = 0;
          int chunk = 0;
          while (((int) size - rb) > 0) {
         chunk = bis.read(bArray, rb, (int) size - rb);
         if (chunk == -1)
           break;
         rb += chunk;
          }//end of while (((int)size - rb) > 0)
          //instantiate the CRC32
          CRC32 crc = new CRC32() ;
          crc.update(bArray, 0, size);
          //instantiate the ZipEntry
          zentry = new ZipEntry(fileName) ;
          zentry.setMethod(ZipEntry.STORED) ;
          zentry.setSize(size);
          zentry.setCrc(crc.getValue());
          //write all the info to the ZipOutputStream
          zos.putNextEntry(zentry);
          zos.write(bArray, 0, size);
          zos.closeEntry();
        catch (ZipException ze) {
          throw ze ;
        catch (FileNotFoundException fnfe) {
          throw fnfe ;
        catch (IOException ioe) {
          throw ioe ;
        catch (UserException ue) {
          throw ue ;
        finally {
          //close all the stream and file
          if (bis != null)
         bis.close();
          if (file != null)
         file = null ;
        }//end of try-catch-finally
    }

    Tried~
    The problem is still here~ >___<
    Anyway, thanks for information sharing~
    The message is:
    Cannot open file: it does not appear to be a valid archive.
    If you downloaded this file, try downloading the file again.
    The problem may be here:
    if (fos != null)
    fos.close() ;
    if (bos != null)
    bos.close();
    if (zos != null)
    zos.close();
    if (file != null)
    file = null ;
    The fos is closed before bos so the last buffer is not
    saved.
    zos.close() is enough.

  • What is the max size of a zip file with the JDK1.5 ?

    Hello everybody,
    I'm a french student and for a project, I need to create a zip file, but I don't know in advance the number and the size of files to include in my zip.
    I wish to know if someone have the answer to my question : what is the max size of a zip file with the JDK1.5 ? I believe that with the JDK1.3, the limit size of a zip was about 2Go, wasn't ?
    Thank you for all answer !
    Good day !
    PS : sorry for my very poor english ;-)

    Here is all I have found for the moment :
    ...Okay, what about my suggestion of creating your own 10GB file?
    Try this:import java.io.File;
    import java.io.RandomAccessFile;
    import java.nio.ByteBuffer;
    import java.nio.channels.FileChannel;
    import java.util.Random;
    class Main {
        public static void main(String[] args) {
            long start = System.currentTimeMillis();
            int mbs = 1024;
            writeFile("E:/Temp/data/1GB.dat", mbs);
            long end = System.currentTimeMillis();
            System.out.println("Done writing "+mbs+" MB's to disk in "+
                    ((end-start)/1000)+" seconds.");
        private static void writeFile(String fileName, int numMegaBytes) {
            try {
                int numBytes = numMegaBytes*1024*1024;
                File file = new File(fileName);
                FileChannel rwChannel =
                        new RandomAccessFile(file, "rw").getChannel();
                ByteBuffer buffer = rwChannel.map(
                        FileChannel.MapMode.READ_WRITE, 0, numBytes);
                Random rand = new Random();
                for(int i = 1; i <= numMegaBytes; i++) {
                    for(int j = 1; j <= 1024; j++) {
                        byte[] bytes = new byte[1024];
                        rand.nextBytes(bytes);
                        buffer.put(bytes);
                rwChannel.close();
            } catch(Exception e) {
                e.printStackTrace();
    }On my machine it took me 43 seconds to create a 1GB file, so it shouldn't take too long to create your own 10GB. Then try zipping that file.
    Good luck.

  • Decrypt Zip File with AES Cryptography

    Hi,
    I want to make a programm to decrypt a zip file with aes cryptography in java with gui.
    Our professor as a help they gave us that code [http://code.google.com/p/winzipaes/source/browse/winzipaes/src/de/idyl/crypto/zip/AesZipFileDecrypter.java?r=4].
    I search in Internet to find out same help for the project but I understood , that other programm don't use all the packages in the example.And i am little confused.
    I want some help to find out a solution for this problem.And if you have a similar programm jusy sent it to occupy how I resolve my own problem.

    As your professor has given you the crypto code and wants you to write the GUI code this is not a Cryptography question at all. Locking this thread.

  • Decrypt Zip File with 128bit AES

    Hello my name is George ,
    I want to make a program to decrypt a zip file with 128-bit AES Algorithm using Brute Force and Dictionary Attack.
    Because it is my first time I try to make something with the encrytpion libraries I don't know much.
    Because that is an exercise they told us to use this library [http://www.javamex.com/arcmexer/].
    So I want to give me some help.
    Any help is welcoming.

    Hi.
    I want to make a program to read a zip file with a password(aes encrytpion) and I foun the password.
    At first i know the password and I want to do If I write it wright.
    I read a zip file but when I try to read it with encryption I take that exception.
    That is the program
    import com.javamex.arcmexer.*;*
    *import java.io.*;
    import java.lang.*;*
    *import java.util.*;
    public class Decryption {
         public static void main(String[] args){
              String pw = "12345678";
              System.out.print("\rEnter the filename to be encrypted (full path is needed if not located at the same directory): ");
                    try {
                   FileInputStream f = new FileInputStream("C://Giorgos.zip");
                   ArchiveReader r = ArchiveReader.getReader(f);
                   ArchiveEntry entry =r.nextEntry();     
                   BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
                            while ((entry = r.nextEntry())!= null) {
                        String filename = entry.getFilename();
                                    InputStream in = entry.getInputStream();
                                    String inputLine = input.readLine();
                                    if (inputLine.equalsIgnoreCase("yes")) {
               +BufferedReader br = new BufferedReader(new InputStreamReader(entry.getInputStream(filename)));+  //HERE IS MY PROBLEM
                                        +String line;+
                                         +while ((line = br.readLine())!= null) {+
                                        +System.out.println(line);+
    <                                    <em>input.close();+
    <                       <em>// }+
    +               if (entry.isProbablyCorrectPassword(pw)){+
    +                    System.out.println("Password found: "+  pw);
              } catch (Exception e){
                        System.out.println("Exception raised!");
    }And the exception is:
    *{color:#0000ff}C:\Documents and Settings\Ergasia\Decryption\src\Decryption.java:26: getInputStream() in com.javamex.arcmexer.ArchiveEntry cannot be applied to (java.lang.String)*
    *BufferedReader br = new BufferedReader(new InputStreamReader(entry.getInputStream(filename)));{color}*

  • Finder crashed after downloading a zip file with pictures

    First my desktop icons disappeared. Then the finder, appears and disappears every 3 seconds. Simultaneously the Finder also disappears and reappers in the "Force Quit Application" window. This started after I downloaded a zip file with family photos from a friend (on a windows machine). Rebooted off the Tiger installation dick. Running disk utility off the Tiger installation disk did not help. Permissions were repaired but the finder is still crashing Tried relaunching the Finder from the "Force Quit Application" window. No help. Ran Virex (outdated by 12 months) without any benefit.
    Any suggestions would be appreciated.

    There's a shameful glitch in Finder where if you drag certain attachments off a mail document onto the Desktop the Finder will do its quit/relaunch jitter bug--will also do it for illegally named files on the Desktop, and will hang for dang near forever it you accidently drop 100s of files onto the Desktop. The easy solution is to start the affected machine in target disk mode, hook it up by firewire to another Mac, then navigate to the affected user's Desktop folder and move the funky file or files into a new folder.
    Francine
    Francine
    Schwieder

  • Pull a zip file with multiple files unzip it, and finally load one of the f

    Hi Aill,
    I have following query.
    Could we do the following with XI: pull a zip file with multiple files from a vendor which resides outside of XI server network, unzip it, and finally load one of the files to SAP?
    Regards
    Rohan S

    Hi Varadharajan,
    I have 10 text files in some ZIP file on one server which is out side of network. We can reach that file through Proxy only to read ZIP file.
    I need to extract the file and on the bases of some condition one of the file i need to upload data to SAP.
    Is it possible. If possible then How?
    Regards

  • How to define new classpath of libraries while making jar files with ant

    I am useing eclipse and ant and trying to make a jar file. I have used some external jar files. I have managed to add external jar files to my jar. But Still I have a problem. In my project all libraries in lib folder. But when I put them into jar file. They are in the root folder.Classpath has changed and It couldn't find the class path.
    Is there any body knows how to define a new class path for external libraries with ANT. or How can I put my libraries into a lib folder in jar ?? I think both of them would solve my problem.
    thanks in advance.
    My code is like that, I think it requires a little modification
    <target name="jar">
            <mkdir dir="build/jar"/>         
            <jar destfile="build/jar/Deneme.jar" basedir="build/classes" >             
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>                    
                </manifest>             
                 <fileset  dir="${lib.dir}" includes="**/*.jar"/>           
            </jar>
        </target>

    I can see why your other "question" was likely deleted. You need to drop the editorial comments and just ask a question. I believe what you want to know is how to configure something using php on your Apache server so that it can be read. If that's your question, here's a couple of places that discuss the topic:
    http://www.webmasterworld.com/linux/3345459.htm
    http://forums.macrumors.com/showthread.php?t=427742
    http://en.allexperts.com/q/PHP5-3508/configuring-installing-permissions.htm
    For a general introduction to 'nix permissions, take a look at this:
    http://www.osxfaq.com/Tutorials/LearningCenter/UnixTutorials/ManagingPermissions /index.ws
    And here's a whole book on the subject of Leopard permissions:
    http://my.safaribooksonline.com/9780321579331
    Try doing a Google search on "leopard permissions php apache" and see if you find what you are looking for.
    Francine
    Francine
    Schwieder

  • Zip file with password using an applescript

    Hi all;
    I want zip a file with a password using an apple script. The problem is that I'll run the command
    zip -ejr outfile infile
    but how do I submit the password to the terminal?
    I don't want the terminal to be visible during the process so I'm using this command:
    tell application "Terminal" to do shell script sh
    where sh is the command I want to run.
    Thank you!

    I'm running out of suggestions over here.
    Your exact command line yields this result:
    zip warning: name not matched: in.txt
    zip error: Nothing to do! (out.zip)
    Well, it should, as I don't have an in.txt. Handing it an existing file, I get this:
    zip -P pass out.zip result.txt
      adding: result.txt (deflated 7%)
    .. and opening in the Finder correctly prompts me:
    so there must be something wrong with your system.
    Very Long Shot: What version do you get when you type this? (I can't imagine this is the actual problem, but you never know.)
    zip --version
    Mine is
    Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
    This is Zip 3.0 (July 5th 2008), by Info-ZIP.
    Currently maintained by E. Gordon.  Please send bug reports to
    the authors using the web page at www.info-zip.org; see README for details.
    Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,
    as of above date; see http://www.info-zip.org/ for other sites.
    Compiled with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) for Unix (Mac OS X) on May 25 2011.

  • Problem downloading ZIP file with Squid-3.0

    Hi,
    I have upgraded my Linux CentOS squid proxy servers to Squid version 3.0. Since then I can not download the following file it just hangs :
    http://download.oracle.com/otn/java/sqldeveloper/sqldeveloper-1.5.5.59.69.zip
    I dont see any error in the squid logs or on my firewall.
    I can however download it on one of the older servers still running Squid version 2.6.
    It is just very strange as I can download ZIP files from any other website with the upgraded servers.
    Any ideas on what might cause this ?
    Thanks
    JHEFER
    Edited by: jhefer on Nov 19, 2009 12:15 AM

    If you have already interested, I found the solution. The problem is that oracle website (and probably others) uses “Vary” field in the header and squid doesn’t support this (by default). You have to download squid sources on http://www.squid-cache.org/Versions/ and compile these with “--enable-http-violations” parameter :
    *./configure ‘--enable-http-violations’ ‘…’ ‘…’*
    make all
    make install
    I hope this solution will be very useful to you.
    Laurent

  • How can I create a zip file with LabVIEW?

    I would like to compress my data (ASCII format) to an archive.
    I use LVZlib.vi to compress and decompress data but I would like to be able to read the output file with a software archiver such as PowerArchiver/WinZIP.
    Someone knows how I can create a file compatible with zip or gz standard format, thanks !

    >> Yes but I have to install a special archiver (with ms-dos ommand line ability
    >> such as pkzip,arc,rar,arj...) on the computer where I install my LV application.
    Search for "gnu tools for windows" and get zip.exe, gzip.exe, bzip2.exe and others (even the source, if you like). These are about 50kB files that run in place (no installation) - easy to include in a distributed app. Oh, since I'm logged in I'll attach a couple, though I don't have the source on this machine).
    Attachments:
    bin.zip ‏67 KB

Maybe you are looking for

  • Family Sharing Setup Question

    Currently, I'm set up where I have an Apple ID that I've been using forever in the iTunes store for music/apps/etc. All the devices in my home are signed into that ID under the iTunes store preferences. Besides that, everyone has their own Apple IDs

  • Since updating to latest version (10.5.1) I cannot open iTunes

    I updated to the latest version of iTunes a few days ago. This is the 10.5.1.42 version. I am running Windows 7 Professional (x86) on a Dell Vostro 200 Slim Tower, 1.2GHz Processor, 4GB RAM, plenty of HDD space available. After updating to that parti

  • How do you compress a photo's MB size?

    I am trying to compress a photo's size from 4MB to smaller however it wont work. My mac just makes slideshows instead. Please give me the correct instructions on how to make the image size smaller. THANK YOU SO MUCH

  • Powerbook upgrades and Display advice????

    Hi there everyone, I've got two question's, as with everything else i've asked, these boards have always helped me. The First One. I've Got a 1.33Ghz PBook, It has never failed me, making the switch was the best thing i ever did, the only problem wit

  • BDC for change customer(XD02)

    Friends, Actually I need to write a BDC to chnage the customer telephone numbers in XD02, but strange that it doesn't get recorded in SHDB properly. How to change the existing telephone numbers as they are in the table control and no function code is