Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Norm

Thread: Unpacking a jar file using pack200

  1. #1
    sublixt's Avatar
    sublixt is offline Member
    Join Date
    Jul 2011
    Location
    somewhere
    Posts
    37
    Rep Power
    0

    Default Unpacking a jar file using pack200

    I am trying to unpack a jar file using pack200 but cannot figure out what i am suppose to have in the input stream.
    Java Code:
    import java.io.*;
    import java.util.jar.*;
    public class test {
    	public static void main(String args[]) throws IOException{
    		String userName = System.getProperty("user.home");
    		File outName = new File(userName +"/Desktop/test.jar");
    		File inName = new File(userName + "/Desktop/tmp");
    		Pack200.Unpacker unpacker = Pack200.newUnpacker();
    	    JarOutputStream out = new JarOutputStream(new FileOutputStream(outName));
    	    InputStream in = new FileInputStream(inName);
    	    unpacker.unpack(in, out);
    	    out.close();
    	}
    
    }
    Java Code:
    Exception in thread "main" java.io.FileNotFoundException: /home/***/Desktop/tmp (Is a directory)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(FileInputStream.java:137)
    	at test.main(test.java:10)
    I know from previous experiences that (Is a directory) means that the path needs to be something other than a directory but what does the path need to be for the pack200 to work?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    The exception is saying that there is a problem with the FileInputStream constructor rather than anything to do with Pack200. The File argument must name a readable file.

    Check that /home/***/Desktop/tmp exists (including spelling and case), is a file and is readable. Do this from the command line or within the code using the appropriate File methods.

  3. #3
    sublixt's Avatar
    sublixt is offline Member
    Join Date
    Jul 2011
    Location
    somewhere
    Posts
    37
    Rep Power
    0

    Default

    i took your suggestion, as well as i could understand, and created a file.txt in the tmp directory re wrote the path and now it is giving me a new error
    Java Code:
    Exception in thread "main" java.io.IOException: Corrupted pack file: magic/ver = 00000000/0.0 should be CAFED00D/150.7 OR CAFED00D/160.1
    
    	at com.sun.java.util.jar.pack.NativeUnpack.start(Native Method)
    	at com.sun.java.util.jar.pack.NativeUnpack.run(NativeUnpack.java:186)
    	at com.sun.java.util.jar.pack.NativeUnpack.run(NativeUnpack.java:235)
    	at com.sun.java.util.jar.pack.UnpackerImpl.unpack(UnpackerImpl.java:121)
    	at test.main(test.java:11)

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Looks like the unpack() method thinks the pack file it is working on is corrupted.
    Does unpack read "packed" files? Or text files?
    pbrockway2 likes this.

Similar Threads

  1. Replies: 1
    Last Post: 07-28-2011, 07:50 PM
  2. Replies: 6
    Last Post: 12-01-2010, 05:31 AM
  3. Replies: 1
    Last Post: 08-04-2010, 03:24 PM
  4. Replies: 8
    Last Post: 02-18-2010, 12:54 PM
  5. Replies: 0
    Last Post: 02-11-2009, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •