Need Help for Jar Files Operations!

Hi,
I am trying to extract files from jar file using the java code. Does any one knows how can one do this using java code.
Or
is there any facility that I can use the unjar command inside the java code to extract it. I wonder about this!
Or
does java povide Java APIs provides facility for this. I have gone thourgh java.util.jar package but am not to get how can this be used for the above purpose?
Thanks.
Huzefa

The following will display each file in the zip/jar file to the screen.
ZipInputStream zin = new ZipInputStream( new FileInputStream( "z:\\myzip.zip" ) );
ZipEntry entry;
while( (entry = zin.getNextEntry() ) != null ) {
     System.out.println( "Entry: " + entry.toString() );
     byte[] buf = new byte[ (int)entry.getSize() ];
     zin.read( buf, 0, (int)entry.getSize() );
     System.out.write( buf, 0, (int)entry.getSize() );
Jar* extends Zip*.

Similar Messages

  • Need help with jar files

    I have made an application that uses the javax.comm library for serial port drivers. It works perfectely but when I put all the .class in a .jar and start the application it starts properly with no errors but it doesn't see the com's of the computer.
    I would apreciate if you could help me out
    greetings
    paul

    You have to modify the source code of the javax.comm class files you are using.. the line contains "package javax.comm;" should be deleted. And then compile those modified files and put the compiled files to your jar file. Or you can create a folder "javax" and subfolder "comm" in that folder and put those original .class files into "javax/comm". After that, put that "javax" folder into your jar file.

  • Need help with Jar file

    I am writing an Application in Java using swing and all that good stuff but I am currently ready to do some beta testing to find any other errors.
    The problems is I want it to be easy to use so I was just going to throw the classes ina jar file so they could just run the jar files.
    For some reason I keep getting a cannot find main class error??
    Here is the manifest file for the Jar file
    Manifest-Version: 1.0
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    Main-Class: VRPServer.class
    VRPServer is the class that has the main in it.
    if I go to the command line and run I get
    E:\JAVA\VRP\Server>java -jar VRPServer.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: VRPServer/class
    if I double click the jar I get a pop-up saying "Could not find the main class, program will exit."
    I really don't understand Jar files all that well, I went through the tutorials but still can't see why this isn't working. Any help is appreciated. :)

    I think your problem is that you shouldn't add the '.class' to the name of your main class in your manifest; it should simply be the fully-qualified name of the class, for example:
    Manifest-Version: 1.0
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    Main-Class: mypackage1.mypacage2.MyClassHope this is all it takes.
    Shaun

  • Need help about jar file again!!

    I want to make some of my package used as library. And also put my application into executable jar file. I edited following codes:
    uner path: D:\dd\b\b1
    package b.b1;
    public class Son
         int x = 10;
         public Son(){
         public int getX(){
              return x;
    under path D:\b\b2
    package b.b2;
    import b.b1.Son;
    public class Father
         public Father(){
         public static void main(String[] args)
              Son son = new Son();
              System.out.println("Hello World!"+son.getX());
    Then I used jar tool make two jar files and also make one of then has specified main class Manifest.mf.
    Here is my steps:
    D:\bb>edit kk.txt
    D:\bb>jar cmf kk.txt father.jar .\b\b2
    D:\bb>jar cf son.jar .\b\b1
    D:\bb>java -jar -classpath .;son.jar father.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: b/b1/Son
    at b.b2.Father.main(Father.java:13)
    I really do not know what's going on?
    Interesting thing is I can get this result:
    D:\bb>java -classpath .;son.jar b.b2.Father
    Hello World!10
    And if the father.jar does not depend on son.jar,
    it is also works.
    Thanks in advance.

    I believe when you run with the -jar option, the classpath setting is ignore and you have to specify classpath in the manifest file.
    From JDK Doc:
    Class-Path :
    The value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path.
    Sounds like you can specify a different path than the current directory, but you have to know beforehand what that path is.

  • Help using jar file!

    Help using jar file!
    Hello
    I have created a jar file by using
    jar cvmf Manifest.txt myjar.jar 1.class Mydirectory
    In 1.java file :I have used
    JEditorPane editor;
    editor.setPage(getClass().getResource("/Mydirectory/default.htm"));
    If I am only giving myjar.jar file to the client without Mydirectory then also it is working fine by showing default.htm in JeditorPane.
    But my problem is I want to use
    Runtime.getRuntime().exec("cmd /c start IEXPLORE"+targetstr) ;
    targetstr will be the filename with path of the default.htm
    If I am giving myjar.jar file with Mydirectory to the client it is working but I don't want to give Mydirectory to the client .
    What should I do?
    Is there any solution for this?
    Using another jar file which will include mydirectory can solve this problem?
    Is there any othe concept in java so that I wll be able to hide Mydirectory from client?
    Please help.

    It seems like you could extract the .htm file from the jar, either with Runtime.exec or using the Jar API classes.

  • Need help for flash builder

    i need help for flash builder 4 and papervison 3d. I need to create a slider with it ranges of value from 10 to 50 to adjust the camera values for the camera.fov and also need to create it for the yaw of the object from 0 to 360. I try to look for any slider event and classes in this program but cant find any, btw, i need to use the AS only project file.
    here is my codes:
    can you please tell me how i should modify the codes?
    package
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.events.Event;
        import org.papervision3d.materials.BitmapFileMaterial;
        import org.papervision3d.materials.BitmapMaterial;
        import org.papervision3d.objects.primitives.Sphere;
        import org.papervision3d.view.BasicView;
        [SWF (width="800", height="600", backgroundColor="0x000000",frameRate="30")]
        public class EarthBitmap extends BasicView
            private var sphere:Sphere;
            public function EarthBitmap()
                super(800 , 600);
                var earthmaterial:BitmapFileMaterial = new BitmapFileMaterial("../assets/Earth.jpg");
                sphere = new Sphere(earthmaterial,100,20,18);
                camera.fov = 25;
                scene.addChild(sphere);
                addEventListener(Event.ENTER_FRAME,rotateSphere);
            public function rotateSphere(evt:Event):void
                sphere.yaw(0.2);
                singleRender();

    Turn the click handler into a full on separate function. Then store all the views in an array and use Math.rand() to randomly choose one.
    Something like this:
    <fx:Script>
         <![CDATA[
              var questionsArray:Array = {question2,question3,question5,questionRed,questionGeography};
              function buttonClickHandler(event:MouseEvent){
                   var randomProblem:int = Math.floor(Math.random()*(questionsArray.length));     //generates a random integer between 0 and the total number of questions in the array (arrays are 0-based)
                   navigator.pushView(questionsArray[randomProblem]);
         ]]>
    </fx:Script>
    <s:Button id="randomProblemButton" label="Next Problem" click="buttonClickHandler(event)" />
    Haven't tested that, but something along that line should work

  • Need help for writing extract program

    hi
    i need help for writing extract program to retriew data from legacy system.
    i already developed bdc programs for me31k and me21.
    my requirement is to write extract program s for those t.codes.
    to retriew data from legacy system and stored in flat file.

    i need help with a java program. it is a program that allows the user to enter a student's GPA, number of extracurricular activities, and number of service activities. The user can not enter a gpa above 4.0 or below 0. The user can not enter a negative number for the number of both activities. If the student meets the following criteria: 1) GPA of 3.8 or above and at least one extracurricular activity and one service activity, 2) GPA below 3.8 but at least 3.4 and a total of at least three extracurricular and service activities, 3) GPA below 3.4 but at least 3.0 and at least two extracurricular activities and three service activities, the message "Scholarship candidate" should display. If the student does not meet the criteria above, then the message"not a candidate" should display. Can you help me, please?
    You haven't posted ANY 'java program' for us to help with.
    The forum is NOT a coding service. It is to help you with YOUR code.
    Post the code you have written and SHOW us (don't just tell us) how you compile it and execute it and the results you get. Then we can help you with any problems you are are having.
    If you need help understanding just what the program should be doing you need to ask your instructor to clarify the assignment.

  • An error occured while trying to copy the needed DB driver jar files

    When I try to run my web app, I see this error in the Output window.
    Creator will also put up a window essentially saying that I don't have a particular
    data source. But I do have that very data source there.
    The error seems to be pointing to this line in my build-impl.xml file
    <nbdeploy debugmode="false" clientUrlPart="${client.urlPart}" forceRedeploy="${forceRedeploy}"/>

    I'm using postgresql-8.1-404.jdbc3.jar
    I started this project with Creator2, so I don't know if the nbproject files
    are out of date or anything.
    Here's the output text:
    init:
    deps-module-jar:
    deps-ear-jar:
    deps-jar:
    Copying 1 file to /home/tc/dev/oms/src
    library-inclusion-in-archive:
    library-inclusion-in-manifest:
    Copying 1 file to /home/tc/dev/oms/build/web/WEB-INF/classes
    load-project-properties:
    installGraphics:
    installLayouts:
    compile:
    compile-jsps:
    pluto-hack-web-xml-run:
    portlet-container-deploy:
    jsCreatorDist:
    run-deploy:
    An error occured while trying to copy the needed DB driver jar files.
    Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    Exception=Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:198)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:75)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:234)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:242)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
    Caused by: An error occured while trying to copy the needed DB driver jar files.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:139)
    ... 10 more
    /home/tc/dev/oms/nbproject/build-impl.xml:799: Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    BUILD FAILED (total time: 7 minutes 21 seconds)

  • I need help for Blackberry8700g

    New User! I need help for Blackberry8700g; It is the error message Java.lang.outofmemory Error. I can not make even phone calls. After reset it is same message pop up and does not off the power jum error523  100408 .I tried How_do_I_wipe_the_BlackBerry_using_Jl_Cmder%3F but it does not allow me to log in.Thanks,Rehan

    check this instruction:
    http://crackberry.com/blackberry-101-lecture-12-how-reload-operating-system-nuked-blackberry

  • Need to download JAR files from more than ONE HTTP-server ?

    Hello,
    We have a need to download JAR files for an application, from more than ONE HTTP-server, i.e. any specified HTTP-server in an extremely secure network.
    Does a solution exist for this requirement ? Is it possible to design a solution our selfes for this problem ?
    Best Regards
    Peter

    We have a need to download JAR files for an
    application, from more than ONE
    HTTP-server, That can be done using the extension element
    from within the resources element of the main JNLP.
    http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources
    The extension element should refer to another JNLP
    (on the other site) that refers to the Jars. The jar files
    in any such (foreign) JNLP need to be signed, and the
    JNLP files should declare itself as a <component-desc>.
    For any level of detail on using extensions/components,
    download the spec. mentioned in the second paragraph
    of that section linked above. Unfortunately I can find no
    web browsable form of the information.
    Here is an example though..
    http://www.javasaver.com/testjs/jws/04/glclock.jnlp
    This (sandboxed) screenaver demo comes off my
    javasaver site. It refers to the JOGL API via an
    extension element in the JNLP, that points directly
    to the JOGL site. You might notice the security
    warning that is produced mentions..
    Name:      JOGL
    Publisher: sun microsystems, inc
    Source:    https://jogl.dev.java.net
    ..i.e. any specified HTTP-server in an
    extremely secure network. I do not know about an extremely secure network,
    but if it is OK to launch a normal JNLP for an
    application with a 'main()' from the server, I guess
    it should be OK to launch extensions off it - you
    might need to set up some tests.

  • Pls i need help for this simple problem. i appreciate if somebody would share thier ideas..

    pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my  desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my  desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...

    If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.

  • I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please

    I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please

    http://www.apple.com/support/itunes/contact/

  • Need help for Format HD

    Hi I need Help for Formating HD so Wat Key need hold on start up for format HD I apprciated you Help

    Jesus:
    Formatting, Partitioning Erasing a Hard Disk Drive
    Warning! This procedure will destroy all data on your Hard Disk Drive. Be sure you have an up-to-date, tested backup of at least your Users folder and any third party applications you do not want to re-install before attempting this procedure.
    • With computer shut down insert install disk in optical drive.
    • Hit Power button and immediately after chime hold down the "C" key.
    • Select language
    • Go to the Utilities menu (Tiger) Installer menu (Panther & earlier) and launch Disk Utility.
    • Select your HDD (manufacturer ID) in left side bar.
    • Select Partition tab in main panel. (You are about to create a single partition volume.)
    • _Where available_ +Click on Options button+
    +• Select Apple Partition Map (PPC Macs) or GUID Partition Table (Intel Macs)+
    +• Click OK+
    • Select number of partitions in pull-down menu above Volume diagram.
    (Note 1: One partition is normally preferable for an internal HDD.)
    • Type in name in Name field (usually Macintosh HD)
    • Select Volume Format as Mac OS Extended (Journaled)
    • Click Partition button at bottom of panel.
    • Select Erase tab
    • Select the sub-volume (indented) under Manufacturer ID (usually Macintosh HD).
    • Check to be sure your Volume Name and Volume Format are correct.
    • Click Erase button
    • Quit Disk Utility.
    cornelius

  • Need help for my requirement...

    Need help for my requirement...
    Hello Experts,
    I have report where users can input the company, housebank, account ID and posting date.
    Now in one column of my report named 'Cash in Bank', I need to get all postings from cash
    accounts with GL code ending in '0'. Now, I know that I can get the amounts in BSIS/BSAS
    but how do I link it with the proper bank and account?
    For example:
                       Cash in Bank
    Bank A
      Account ID 1     1,000,000
      Account ID 2     25,000,000
    Hope you can help me guys. Thank you and take care!

    hi Viraylab,
    each house bank you can find in table T012, in T012K you'll find the bank accounts to the housebank, the G/L account will be in T012K-HKONT.
    hope this helps
    ec

  • Need help for importing oracle 10G dump into 9i database

    hi, Someone help me to import oracle 10G dump into 9i database. I'm studying oracle . Im using oracle 10G developer suite(downloaded from oracle) and oracle 9i database. I saw some threads tat we can't import the higher version dumps into lower version database. But i'm badly need help for importing the dump...
    or
    someone please tell me the site to download oracle 9i Developer suite as i can't find it in oracle site...

    I didnt testet it to import a dump out of a 10g instance into a 9i instance if this export has been done using a 10g environment.
    But it is possible to perform an export with a 9i environment against a 10g instance.
    I am just testing this with a 9.2.0.8 environment against a 10.2.0.4.0 instance and is working so far.
    The system raises an EXP-00008 / ORA-37002 error after exporting the data segments (exporting post-schema procedural objects and actions).
    I am not sure if it is possible to perform an import to a 9i instance with this dump but maybe worth to give it a try.
    It should potentially be possible to export at least 9i compatible objects/segments with this approach.
    However, I have my doubts if this stunt is supported by oracle ...
    Message was edited by:
    user434854

Maybe you are looking for

  • Client not installing on Windows 7

    Have a new Windows 7 box, using SCCM 2012, the SCCM client is not installing, I'm pushing it out via GPO , it has a folder on the WIN7 box. the log file has the following, let me know if this is enough information or if more is needed. this is the la

  • I have problem with application on my nokia 5310.....

    hi i restart my Nokia in setting from my phone after that when i go to my application it's give me error and all my images and game i had is gone and application like IM and Mobil email is not working any idea how to fix this thank you

  • Updating a component outside the context of the f:ajax element

    Is there a way to make the following code work, apart from placing the "out" component inside the h:form element? <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"           "http://www.w3.org

  • Is it possible to set a "query in change mode" with the Report Designer 7.x

    Hi, I have a query set in "change mode"  with an index set as "data can be changed using user entries or planning funcionts". If I use this query as a "Data Provider" in the Report Designer, the result is still in "change mode" or a result of the Rep

  • Hyperlinks within a document

    I would like to know if it is possible to link within a document (i.e. to have a table of contents and link to each section within a document) and if so, how do you do it?? I also have hyperlinks embedded within the same document and I would like to