Extract jar file

how do i expand/extract a .jar file so i can read all the classes and figure out how the program works?

Open it with winzip/winrar. Extract all the class files. Run a Java decompiler on them.
If you weren't able to figure this out though, you're probably not going to understand the decompiled code.

Similar Messages

  • How to extract jar files into  a folder in the local disk and then import?

    hai forum,
    will any one tell me how should i extract jar files into a location in my project folder and then how to import the class files for further usage?
    Thank you .

    I will be graeateful if u could explain this a bit.
    Do you want to say that i should craete instance of
    ZipEntry like this
    InputStream is =
    jarFile.getInputStream(entry);
    File inputFile = new
    File("C:\\myclasses.data");
    FileInputStream fis=
    new FileInputStream(inputFile);No! You need to write the entry using FileOutputStream copying all the bytes of the ZipEntry InputStream to the FileOutputStream.
    >
    What about adding into a directory?Do i have to
    create on dynamically?Yes! You can use File.mkdirs(). For example
                        File ofile = new File("your directory where you will place the zip entries" + zipEntry.getName());
                        ofile.getParentFile().mkdirs();

  • Extract JAR file to a different directory

    Is it possible to use the jar command to extract the content of a JAR file to a different directory (not the current directory)?
    I want to use this command inside a makefile, looking for the same effect as "unzip example.jar -d directory".
    Thanks in advanced.

    Thanks Chuck, you solved my doubt... It surprises me that JAR doesn't support this option.
    I used the "unzip" command inside the makefile instead, but I wanted to be sure that there wasn't any chance to use "jar" (without using the additional script file).

  • How to extract JAR file in particular directory

    Hi,
    I am extracting a JAR file(A.jar) in a Makefile
    Now the path of the Makefile is say /home/developer/
    The location of the JAR file is in /opt/tools/mk/A.jar
    I am extracting the jar file as:
    jar xvf /opt/tools/mk/A.jar
    This creates a directory named "A" under /home/developer, since the location of the Makefile is at /home/developer.
    Question) How do I unjar /opt/tools/mk/A.jar under /opt/tools/mk/ itself, irrespective of the location of the Makefile?
    thanks

    jar -?
    Usage: jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] [-C dir] files ...
    Options:
        -c  create new archive
        -t  list table of contents for archive
        -x  extract named (or all) files from archive
        -u  update existing archive
        -v  generate verbose output on standard output
        -f  specify archive file name
        -m  include manifest information from specified manifest file
        -0  store only; use no ZIP compression
        -M  do not create a manifest file for the entries
        -i  generate index information for the specified jar files
        -C  change to the specified directory and include the following fileI'd say you may want to try the -C option

  • Download and extract jar file from applet

    Can any one provide me a solution for my below problem. Thanks in advance for all the suggestions.
    I want my applet to download a jar file, extract into users home directory by creating a folder and then set the created folder to java library path.
    My applet html file is in "root" directory. The applet is included into applet.jar and placed under "lib" directory which is under "root" directory.
    Now i also had another jar file(contains dlls what I packed) under the same lib folder.
    The below is the following directory structure in my server.
    root ---
         |
         |
         default.html
         lib--
         |
         |
         applet.jar - contains applet related classes
         native.jar - contains dlls which are to be loaded
    When a client downloads my applet, it should copy the native.jar and then extract into a new folder under user home directory. Then set this folder to java library path.
    Regards
    raman kumar

    I managed to do it this way, Just remember that you need to sign the jar files for your applet, else it won't work.
    package jar.extract;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.jar.JarFile;
    import java.util.zip.ZipEntry;
    public class JarExtractor {
         // Dll file in the jar
         private static String JAR_FILE = "dll.jar";
         public void extract() {
              try {
                   JarFile jf = new JarFile(JAR_FILE);
                   // Entry in the jar file rember package and dll file
                   ZipEntry ze = new ZipEntry("package/dll_file");      
                   int length = (int) ze.getSize();
                   byte fileContent[] = new byte[length];
                   InputStream fin = jf.getInputStream(ze);
                   fin.read(fileContent, 0, length);
                   // CODE missing.
                   // You need to write the input stream (fin) to a new files output stream
                   // it is like copying a file !!!
              } catch (IOException e) {
                   e.printStackTrace();
    }Tom

  • Extracting JAR files and reading their contents

    Hi,
    I have a JAR files which contains classes in different packages also a config file which is also in some package structure.
    I have to read that config file, which will inturn have other file names, i have to read the filename and read the actual content of the file spcified in the config file.
    Can some one help me out with a simple example... ?
    I have tried with java.util.zip... I can read the name of all the files in JAR to any depth.. but couldn't open and read the required file.
    Thanks in advance...
    Thanks & Regards,
    Gurushant Hanchinal

    Hello you can see the content of a jar file with this line
    jar tf filename.jarand extract with
    jar xf filename.jar

  • Extract contents of a .Jar file or executable jar file

    I have an executable Jar file.. Is there anyway that I can see the contents of this file.. the code in it..
    I have read some tutorials on how to extract .jar files but the question is where do i execute these commands.. is it on the command window or somewhere else.
    Can anyone help me plz????????

    but the question is where do i execute
    these commands.. is it on the command window or
    somewhere else.
    If you're using windows OS, you can do execute the
    command in dos promt
    and if you're using linux, you execute it in the
    Terminal/Console or double click on the file name in
    the
    Knoqueror, you can see the contents.Konqueror file manager,you can see the contents.

  • Easy way to extract a jar file?

    I'm looking for an easy way to extract a jar file from with in a java program. I would also like to specify what directory it goes into. I can't seem to find anything on this.

    >
    ...I can't seem to find anything on this.>Where were you looking, under the bed and in the closet? Try [search: extract jar Java|http://lmgtfy.com/?q=extract+jar+Java].
    As to specifying a directory, offer the end user a JFileChooser set to browse directories only.

  • How to extract html file and folder from jar file

    Hi all ,
    I should to submit my project tomorrow . plz help me .
    In my project jar file I have html page that should run when I use the program, I can't extract it . Also it have folder that contain some files that My program should use it . I dont know how to use it from jar file or how to extract it . plz help me.
    If you could I need java could for that.
    Thanks alot.

    Hi all ,
    I should to submit my project tomorrow . plz help me .
    In my project jar file I have html page that should run when I use the program, I can't extract it . Also it have folder that contain some files that My program should use it . I dont know how to use it from jar file or how to extract it . plz help me.
    If you could I need java could for that.
    Thanks alot.

  • How to ban extracting from .jar file?

    Hello
    Problem of .jar file is: .class files can be extracted (with winrar ...) and decompiled. I don't want my classes to be decompiled. But I still need my jar executable of course.
    Is some solution which bans extraction without any impact on executability?
    Thank you very much.
    Tony

    Is some solution which bans extraction without any
    impact on executability?Hmmmm you could not put any class files in your jar. That would eliminate the extraction problem. Probably would be detrimental to execution.
    What do you think happens when your app runs? It just magically knows about your classes without extracting them?
    Not so much no.
    Use an obfuscator.
    Or if that's not good enough use another language or just panic.

  • How to extract the contents of the Jar file?

    Hello,
    Can anyone tell me how to extract the contents of the Jar file?
    An example will be highly appreciated.
    Thanks.

    From command line, or from within a java application?
    Kaj
    Btw. Why do you need to do it. You do know that you can add jars to the classpath and read resources from them without extracting the file?

  • Problem parsing XML with schema when extracted from a jar file

    I am having a problem parsing XML with a schema, both of which are extracted from a jar file. I am using using ZipFile to get InputStream objects for the appropriate ZipEntry objects in the jar file. My XML is encrypted so I decrypt it to a temporary file. I am then attempting to parse the temporary file with the schema using DocumentBuilder.parse.
    I get the following exception:
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element '<root element name>'
    This was all working OK before I jarred everything (i.e. when I was using standalone files, rather than InputStreams retrieved from a jar).
    I have output the retrieved XML to a file and compared it with my original source and they are identical.
    I am baffled because the nature of the exception suggests that the schema has been read and parsed correctly but the XML file is not parsing against the schema.
    Any suggestions?
    The code is as follows:
      public void open(File input) throws IOException, CSLXMLException {
        InputStream schema = ZipFileHandler.getResourceAsStream("<jar file name>", "<schema resource name>");
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;
        try {
          factory.setNamespaceAware(true);
          factory.setValidating(true);
          factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
          factory.setAttribute(JAXP_SCHEMA_SOURCE, schema);
          builder = factory.newDocumentBuilder();
          builder.setErrorHandler(new CSLXMLParseHandler());
        } catch (Exception builderException) {
          throw new CSLXMLException("Error setting up SAX: " + builderException.toString());
        Document document = null;
        try {
          document = builder.parse(input);
        } catch (SAXException parseException) {
          throw new CSLXMLException(parseException.toString());
        }

    I was originally using getSystemResource, which worked fine until I jarred the application. The problem appears to be that resources returned from a jar file cannot be used in the same way as resources returned directly from the file system. You have to use the ZipFile class (or its JarFile subclass) to locate the ZipEntry in the jar file and then use ZipFile.getInputStream(ZipEntry) to convert this to an InputStream. I have seen example code where an InputStream is used for the JAXP_SCHEMA_SOURCE attribute but, for some reason, this did not work with the InputStream returned by ZipFile.getInputStream. Like you, I have also seen examples that use a URL but they appear to be URL's that point to a file not URL's that point to an entry in a jar file.
    Maybe there is another way around this but writing to a file works and I set use File.deleteOnExit() to ensure things are tidied afterwards.

  • Extract a jar file

    Hi Everyone,
    I have a .jar file which contains some java packages. How can extract this file to view the package contents.
    Thanks a lot.
    Hung

    You can open the jar file with an extraction program (like winzip, or tar) or you can try
    jar -xvf [jarfile]
    from the command line

  • Protecting your jar file from been extracted

    Please i noticed that the java jar file of a software can easily be extracted to review the class files with winrar which allows just anyone to have access to your class file and decompile to get source codes, allowing pirating of the software. How can I lock the jar file to prevent extraction of my class files.

    1. why are you mocking others instead of answering the question ? some one wants to protect his jar file. the solution is simple.
    2. you can use google to search, here is result :
    http://stackoverflow.com/questions/1280702/protecting-java-jar-files-for-distribution
    http://stackoverflow.com/questions/9633455/how-to-protect-a-jar-file-from-being-decompiled
    http://www.thegeekstuff.com/2008/06/protect-your-java-code-from-reverse-engineering/
    http://answers.google.com/answers/threadview/id/431511.html
    http://stackoverflow.com/questions/1879061/how-to-protect-java-codes-against-decompiler
    http://viralpatel.net/blogs/2009/07/protect-java-code-decompilation-using-java-obfuscator.html
    http://www.coderanch.com/t/430716/java/java/Protect-class-file-not-decompile
    http://stackoverflow.com/questions/7324708/are-jar-file-insecure-what-can-done-apart-from-code-obfuscation
    http://stackoverflow.com/questions/3647255/how-do-i-copy-protect-my-java-application
    http://www.javaworld.com/javaworld/javatips/jw-javatip22.html
    http://stackoverflow.com/questions/12088/do-you-obfuscate-your-commercial-java-code
    3. it is true if you can use basic methods that EJP mentioned, there would be no need for obfuscators, nor native library use.
    but there are many situations that you can't do any of those methods.
    4. EJP claims that he probably is the one "who have had perhaps 40 times as long as you've had to think about it."
    here is the problem that made me use both obfuscation and native library :
    My company released a simple java library that scanned a document (directly from scanner or camera device).
    the documents were exam papers.
    Use some OCR techniques to convert image to text so some other application could calculate the score using it's api.
    For marketing purposes, the company needed to publish a 7-day trial version of this library.
    So, as you can see I'm eager to hear what you want to suggest.

  • How to extract ZIP/JAR files?

    Hello,
    How can I extract zip/jar files ?
    Eric

    If you are talking java, you can use the java.util.zip classes.
    ZipFile, ZipEntry, ZipInputStream, ZipOutputStream
    You can find lots of examples through google:
    http://www.google.com/search?hl=en&q=java+zip+code+example&meta=Cheers,
    evnafets

Maybe you are looking for

  • More help with Skillbuilders' Modal Page Plugin

    I have an employee page with a series of smaller report regions showing things like contact addresses, job roles, etc. All are form-on-a-table+report type of setup I would like to convert to modal pages. The popup is now working (thanks to a security

  • Sharing files on different pc

    Hi, first of all i want to excuse me because of my bad english, i'm really sorry! then, i try to explain my question: i started to use iTunes 6 in order to organize all my music collection. The aim was to convert all my CDs into mp3 file format, assu

  • ITunes application could not be opened. error 13008

    I've got a 500GB USB3 drive that has an iTunes library on it and that's all it has on it. I've attached the drive to a Negear R6300 router that has a USB port for attaching a network drive. ReadyShare sees it and I can mount it as a Volume that shows

  • Purchase Organation Disappearing after cancelliation of Assignments

    HI, step1: i was created purchase requisation Of Type K - Cost center using me51n Transaction. step2: after that using ME54n Tcode i was release that purchase Requisation and saved. step 3: after releasing go to T code ME57  and execute Me57 Tcode fo

  • I'm trying to export a photo from iPhoto to lightroom....

    it keeps popping up with an error box saying that I don't have enough disk space. Have checked & I have plenty. I'm trying to export an 'original' raw file.....please help?