Problems on zipping and unzipping class files

I am trying to add a class file to a new jar file using FileInputStream and JarOutputStream.
I am getting a very unique problems.
when I read a class file using FileInputStream from my local hard disk I am getting 30 bytes less than then actual file size (the difference in bytes is exactly 30 bytes for any file, either class or xml or java, I dont understand this concept). after reading the contents I am writing the bytes read to a jar file using JarOutputStream. This all gets done fine. But when I extract the class file written into the jar file and try to run the class it is giving me the exception as follows:
java.lang.ClassNotFoundException: com.wipro.flowbrix.plugins.factory.NewClass
Exception in thread "main" java.lang.ClassFormatError: com/wipro/flowbrix/plugins/factory/NewClass (Bad magic number)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
The classpath to the folder from where I am running the file is set. I have double checked the classpath.
any information or solutions regarding this would be of great help.

A "magic number" is a short sequence of data at the beginning of a file used to identify the file. ".class" files, for instance, always start with OxCA, 0xFE, 0xBA and 0xBE.
If the 30 bytes missing are at the beginning of your file, there's nothing suprising in getting a "ClassFormatError" exception.
I think we should concentrate on your first problem. Can you post the code used to add the class file, please?
/Stephane

Similar Messages

  • Third party component for zipping and unzipping using password

    Hi EveryBody
    I am working on a project wherein i have to zip and unzip a file using password .I downloaded a java component ,but was unable to efficiently unzip my zip files using password.
    Can any body suggest me a java library/component that will accept a file and do zipping and unzipping with a password.
    I will also be really grateful ,if somebody suggest me a component that would do the same above functionality using Streams.
    Eagerly waiting for your replies ASAP.
    --Kiran                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    HI
    I am also facing the same sort of problem. Could any body please give some solution for this.
    Ravi

  • Zipping  and Unzipping Directories and files both - URGENT PLEASE

    Hi friend,
    I tried for zipping and unzipping but it is not working still.
    and have to submit project tomorrow.
    so please as possible as fast just send me the source code that zip the file/folder and unzip in the same way as it was stored.
    ex : if we zip file c:/temp/myfolder/myfile.ppt to .zip
    unzip should c:/temp/myfolder/myfile.ppt
    thanks
    ghanshyam
    9879152949

    I believe (although I don't want to put words in his mouth) that Madan has run across a similar problem that I am trying to solve.
    For instance if I have the following files:
    c:\pic1.gif
    c:\pic2.gif
    c:\pic3.gifand I zip them in to a file called: pics.zip the will unzip just fine.
    However, if I have them in a directory:
    c:\pics\pic1.gif
    c:\pics\pic2.gif
    c:\pics\pic3.gifA listing of the zip files (all using java of-course) will show the files and dirs correctly:
    \pics\pic1.gif
      \pics\pic2.gif
      \pics\pic3.gifbut will give the following error if you try to un-zip them:
    "The system cannot find the path specified"The ZipEntry class has an 'isDirectory()' method, but it only returns true in the case of an EMPTY directory. If , as in my example, there is an actual file at the end of the entry, it returns false.
    So, at least in my case, I would be looking for advice on how to expand files that reside in directories within the zip file.
    Thank You for any help you can provide

  • Zip and Unzip files in PlayBook

    Hello all,
    Just a heads up, File Browser for PlayBook will shortly be getting an update that will allow the users to zip and unzip files. Network browsing is planned for the update after this one (free upgrade ofcourse). 
    Here is a link to the app: File Browser
    My apps: Offline Viewer and FlashLight

    that'd be great, I hope that the wait is worthy!

  • Setting up the class root directory and choosing class files.

    I made a simple test application as it is proposed at the J2EE 1.4 Tutorial and all worked.
    (Chapter 24 Getting started with Enterprise Beans)
    Than I deleted the ear file to try out the deploy mechanism again.
    And after generating the new application with File-> New application which worked well I also
    tried to use the EJB Wizard feature of the J2EE deployment tool. After I had selected the appropriate EJB classes to add to my jar, I clicked NEXT and I got the following message:
    The class (converter.Converter) could not be loaded:
    Please consult online help for assistance in setting up the class root directory and choosing class files.
    The online helps isnt very usefull for this type of problem.
    Do you have a hint what to do ?

    Hi san-deepu,
    I couldn't reproduce the error you are having when I followed Ch. 24 tutorial in packaging the ear. Is there anymore information in deploytool's logfile? This is in <user_home>/.deploytool/logfile, or you can run in verbose mode: <as_install>/bin/deploytool -v
    When you say you deleted the ear file, did you also close the ear file in deploytool first? You may also want to exit deploytool () , and try deleting the temporary files. Deploytool usually cleans up the temp files automatically upon exit - maybe there are some left behind that it couldn't delete. On windows the temporary files are located by default in C:\Documents and Settings\Administrator\Local Settings\Temp\sun-dt-Administrator. In deploytool go to Edit --> Preferences --> General to find what the temporary directory is set to.
    Which version of the appserver are you using? jdk version? operating system?
    J

  • Deploying the JSPs, Servlets and Java class files

    Hello All,
    I'm very new to the Oracle 9i AS. We are using Version 1.0.2.2.
    How do we deploy the JSPs, Servlets, and Java class files (simple class files, not EJBs)?
    plese give us the procedure and stpes how to deply or the links for the same.
    Thanks,
    Santhosh.

    Hi
    I guess u r running apache-jserv as servlet engine for your jsp and servlets. If its so, jsp files can be run without any additonal configuration by putting the jsp file under document root or any subdirectory and for running servlets u have to add classpath entries for your servlet in jserv.properties file.
    To make sure that your servlet engine is working, try
    http://servername:port/servlet/IsItWorking, if u get success msg that means servlet engine is working fine.
    Hope this will help
    Regards
    Kumaran

  • Zip and extract multiple files using java program

    how can i zip and extract multiple files using java program.

    Hi,
    Look into the java.util.zip and java.util.jar they expose methods to manipulate zip and jar files.

  • Decrypt and unzip a File + read a XML file received into the ZIP

    Hello,
    I need your help to develop some a complex Biztalk application.
    Here're my needs :
    Our Busness partner send us a zip file cripted with a standard PGP(Pretty Goof Privacy).
    The zip containts an XML file that i have to deal it, and some attachments file(PDF).
    So i need to know what's the best approach for the developpement of my application.
    I want to decrypt the ZIP and then Unzip the file and them read the XML file received in the zip.
    Knowimg that we already have the pipeline compenent to dectypt the file with the strandar PGP and an other pipeline compenent to unzip the File.
    Thank you

    Hi ,
    Try this code to unzip the file and send the xml message .If u face issue let me know
    namespace BizTalk.Pipeline.Component.DisUnzip
    using System;
    using System.IO;
    using System.Text;
    using System.Drawing;
    using System.Resources;
    using System.Reflection;
    using System.Diagnostics;
    using System.Collections;
    using System.ComponentModel;
    using Microsoft.BizTalk.Message.Interop;
    using Microsoft.BizTalk.Component.Interop;
    using Microsoft.BizTalk.Component;
    using Microsoft.BizTalk.Messaging;
    using Ionic.Zip;
    using System.IO.Compression;
    [ComponentCategory(CategoryTypes.CATID_PipelineComponent)]
    [System.Runtime.InteropServices.Guid("8bef7aa9-5da5-4d62-ac5b-03af2fb9d280")]
    [ComponentCategory(CategoryTypes.CATID_DisassemblingParser)]
    public class DisUnzip : Microsoft.BizTalk.Component.Interop.IDisassemblerComponent, IBaseComponent, IPersistPropertyBag, IComponentUI
    private System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager("BizTalk.Pipeline.Component.DisUnzip.DisUnzip", Assembly.GetExecutingAssembly());
    #region IBaseComponent members
    /// <summary>
    /// Name of the component
    /// </summary>
    [Browsable(false)]
    public string Name
    get
    return resourceManager.GetString("COMPONENTNAME", System.Globalization.CultureInfo.InvariantCulture);
    /// <summary>
    /// Version of the component
    /// </summary>
    [Browsable(false)]
    public string Version
    get
    return resourceManager.GetString("COMPONENTVERSION", System.Globalization.CultureInfo.InvariantCulture);
    /// <summary>
    /// Description of the component
    /// </summary>
    [Browsable(false)]
    public string Description
    get
    return resourceManager.GetString("COMPONENTDESCRIPTION", System.Globalization.CultureInfo.InvariantCulture);
    #endregion
    #region IPersistPropertyBag members
    /// <summary>
    /// Gets class ID of component for usage from unmanaged code.
    /// </summary>
    /// <param name="classid">
    /// Class ID of the component
    /// </param>
    public void GetClassID(out System.Guid classid)
    classid = new System.Guid("8bef7aa9-5da5-4d62-ac5b-03af2fb9d280");
    /// <summary>
    /// not implemented
    /// </summary>
    public void InitNew()
    /// <summary>
    /// Loads configuration properties for the component
    /// </summary>
    /// <param name="pb">Configuration property bag</param>
    /// <param name="errlog">Error status</param>
    public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)
    /// <summary>
    /// Saves the current component configuration into the property bag
    /// </summary>
    /// <param name="pb">Configuration property bag</param>
    /// <param name="fClearDirty">not used</param>
    /// <param name="fSaveAllProperties">not used</param>
    public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)
    #region utility functionality
    /// <summary>
    /// Reads property value from property bag
    /// </summary>
    /// <param name="pb">Property bag</param>
    /// <param name="propName">Name of property</param>
    /// <returns>Value of the property</returns>
    private object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)
    object val = null;
    try
    pb.Read(propName, out val, 0);
    catch (System.ArgumentException )
    return val;
    catch (System.Exception e)
    throw new System.ApplicationException(e.Message);
    return val;
    /// <summary>
    /// Writes property values into a property bag.
    /// </summary>
    /// <param name="pb">Property bag.</param>
    /// <param name="propName">Name of property.</param>
    /// <param name="val">Value of property.</param>
    private void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val)
    try
    pb.Write(propName, ref val);
    catch (System.Exception e)
    throw new System.ApplicationException(e.Message);
    #endregion
    #endregion
    #region IComponentUI members
    /// <summary>
    /// Component icon to use in BizTalk Editor
    /// </summary>
    [Browsable(false)]
    public IntPtr Icon
    get
    return ((System.Drawing.Bitmap)(this.resourceManager.GetObject("COMPONENTICON", System.Globalization.CultureInfo.InvariantCulture))).GetHicon();
    /// <summary>
    /// The Validate method is called by the BizTalk Editor during the build
    /// of a BizTalk project.
    /// </summary>
    /// <param name="obj">An Object containing the configuration properties.</param>
    /// <returns>The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator.</returns>
    public System.Collections.IEnumerator Validate(object obj)
    // example implementation:
    // ArrayList errorList = new ArrayList();
    // errorList.Add("This is a compiler error");
    // return errorList.GetEnumerator();
    return null;
    #endregion
    /// <summary>
    /// this variable will contain any message generated by the Disassemble method
    /// </summary>
    private System.Collections.Queue _msgs = new System.Collections.Queue();
    #region IDisassemblerComponent members
    /// <summary>
    /// called by the messaging engine until returned null, after disassemble has been called
    /// </summary>
    /// <param name="pc">the pipeline context</param>
    /// <returns>an IBaseMessage instance representing the message created</returns>
    public Microsoft.BizTalk.Message.Interop.IBaseMessage
    GetNext(Microsoft.BizTalk.Component.Interop.IPipelineContext pc)
    // get the next message from the Queue and return it
    Microsoft.BizTalk.Message.Interop.IBaseMessage msg = null;
    if ((_msgs.Count > 0))
    msg = ((Microsoft.BizTalk.Message.Interop.IBaseMessage)(_msgs.Dequeue()));
    return msg;
    /// <summary>
    /// called by the messaging engine when a new message arrives
    /// </summary>
    /// <param name="pc">the pipeline context</param>
    /// <param name="inmsg">the actual message</param>
    public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
    IBaseMessage Temp = inmsg;
    using (ZipFile zip = ZipFile.Read(inmsg.BodyPart.GetOriginalDataStream()))
    foreach (ZipEntry e in zip)
    var ms = new MemoryStream();
    IBaseMessage outMsg;
    outMsg = pc.GetMessageFactory().CreateMessage();
    outMsg.AddPart("Body", pc.GetMessageFactory().CreateMessagePart(), true);
    outMsg.Context=inmsg.Context;
    e.Extract(ms);
    string XMLMessage = Encoding.UTF8.GetString(ms.ToArray());
    MemoryStream mstemp = new System.IO.MemoryStream(
    System.Text.Encoding.UTF8.GetBytes(XMLMessage));
    outMsg.GetPart("Body").Data = mstemp;
    _msgs.Enqueue(outMsg);
    #endregion
    Thanks
    Abhishek

  • How to zip and unzip files in Mac OS X

    Hi There,
    I want to know how can I unzip and zip my files and folder in mac. Also is there any software that can unzip .rar files in mac. Any help will be appreciated.
    Thanks in advance.

    how can I unzip and zip my files and folder in mac
    To make a zip file, select your file in the finder and then File > Create Archive.
    If you start Mac Help, and type "zip" into the search field, you'll find out more.

  • How can i run a program outside of Forte? (Forte and java/class files)

    im making a program with forte... and i have a bunch of class files, i form file and a java file... how can i put these in one file so poeple without forte can run it...
    thanks

    jmburns wrote:
    I am trying to do a silent install of a program I built using LabVIEW 8.5.  I also need to call an exe after the installation, so I am using the "run executable after installation" option on the Advanced tab of the installer.  I then pass the following command lines to the setup.exe:
    /qb /acceptlicenses yes /r
    This installs the LabVIEW program successfully, but does not then run the additional exe afterward.  If I run the setup.exe normally (with no command line parameters), the additional exe gets run.
    Thanks,
    Jason
    This problem is fixed in a future release of LabVIEW. Here's the CAR ID 67549 for tracking purposes.
    Message Edited by Bob P on 07-10-2008 09:10 AM

  • Problems trying to "hot-deploy" class files in iPlanet. Want to deploy a compiled class (i.e. servlet, jsp) without having to bounce the server. Known issue in iPlanet? How can I get around?

    Currently iPlanet is not allowing us to hot deploy a modified class file(i.e., servlet) as it advertises. It doesn't seem to have a problem with jsp's however. But everytime we modify a servlet(say in an emergency), and wish to deploy, we still have to bounce the KJS. We would like to avoid this if possible. How? I heard this might be a known issue in iPlanet.

    I apologize but this is a clarification of this problem. We are having a problem dynamically reloading java classes that are referenced by jsp's and servlets. The problem DOES NOT exist when trying to reload jsps or servlets themselves. We would like to reload these classes without having to restart the processes. Any thoughts would be helpful. Thanks.

  • Zipping and unzipping

    Hello @ll,
    does anybody know how to pack and unpack files with ABAP? Especially handling files in zip- and rar-format.
    Thanks for any helpfull answers.
    Chris

    Hi Chris,
    For Unzipping files check,
    UNZIP file from ABAP
    for file zipping,
    Zip PDF files for BSP response
    Also check the doc,
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c6b79908-0a01-0010-8ca0-b77aff37726d
    Regards,
    Hema.
    Reward points if it is useful.

  • Problem using payloadZipBean to unzip a file

    I would like to run OS command to zip large amount of xml into one zip file before XI pick it up, then use unzip option in payloadZipBean to unzip all the xml files so XI can process them one by one from memory, this will reduce lots file I/O time.
    But I am getting this warning message:
    Warning Zip: message is empty or has no payload
    But if I display this message in RWB, the only payload is this zip file.
    Why the payloadZipBean is not unzipping this file as supposed to.

    Did you check this blog
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    Sameer

  • Is it possible to zip and use java file in jar?

    there are 2 cases:
    1. only zip no-package java files in a jar file:
    i.e.
    ------------zip
    NoPack0.java (they are no package)
    NoPack1.java
    NoPackN.java
    ------------as NoPack.jar
    2. zip both no-package and packaged java files in a jar file
    i.e.
    ------------zip
    NoPack0.java
    NoPackN.java
    pack\HasPack0.java (they are packed in 'pack')
    pack\HasPackN.java
    ------------as HasPack.jar
    my question is:
    for 2 cases above, if both, one or none of them can be use as a jar file in -classpath for javac compiler?
    thx

    has my Q been answered?

  • I am able to compile a java file in eclipse inspite of compilation errors shown in eclipse and a .class file is generated

    Hi,
    I had a java file with compilation errors as shown in eclipse IDE.
    But the class file is still generated in the classes folder on building and pressing clean the project.
    I confirmed that the class file has an updated time stamp and also that a System.out.println() statement that i added was indeed printed out when this class was encountered during the running of a web application in which this class was called somewhere.
    (The java class has no subclasses and it is a single class with public modifier).
    How does it happen so?
    Regards,
    Karthik.

    As far as I know, the java code is compiled in Eclipse as soon as you save it. i.e. press CTRL+SHIFT+s
    as far as the build is concerned, in case you have a build file where you specify how to make a jar file, the location the jsr file is to be placed, only then you have to build the project. However again, as far as just simple compile is concerned as soon as you save the files are compiled. And show you the errors if any in the tasks window.

Maybe you are looking for

  • FF12 has "Improvements to "Find in Page" to center search result". How can I disable this centering?

    FF12 came with new feature - centering of search result. This is rather annoying feature, when one searches for some small word or number on a bigger screen with at least 40-50 long lines of text, because it may be difficult to see the highlighted re

  • X11 keeps crashing on launch

    When ever I start X11 (either clicking or by connecting with ssh -X, it goes into a cycle of start-crash-pause-start-crash-pause... I get an error stating that it does not understand a color depth of -1. Based on some information from elsewhere I tri

  • In WM is it possible to have a TR's for Inbound and Outbound deliveries?

    Hi All, In WM is it possible to have a TR's for Inbound and Outbound deliveries? In WM is possible to create a TO without TR being created? Please let me know the configuration for the same! Thanks in advance, Kumar

  • Black Line through Video

    Im creating a video presentation for my community colleges Graphics / Multimedia Department. Ive used FCE very little so im still a novice. I create some text in LiveType and made a video clip of it. In FCE i imported the text and the Lower Third it

  • Upgrade - 3 way match data conversion

    I am on an upgrade project(erp 6), the question posed to me is: What is the best way to convert data to new system when there is a PO and a GR, but no IR at the moment ? Previously this company did upgrades and for this scenario, left the items in le