Re: How to include an external (binary) file into a java program at compile (!) time ???

From: Ankur Bulsara (hotmail_at_N0_SPAM_gmail.com)
Date: 10/01/04

  • Next message: Mike B: "Re: Creating a .jar package file"
    Date: Thu, 30 Sep 2004 17:07:11 -0700
    
    

    One way to archieve resource bundling at compile time is to package the
    resources in a jar. Then at runtime, you read in the resource using the
    classloader.

    Here is a file that gets a resource from the classloader:
    http://www.koders.com/java/fid92BF1D1C6E5D4FF57B19FE8B65A49A98E0E77FF1.aspx?s=getresourceasstream

    -Ankur

    "Tobias Merler" <merlin@gmx.net> wrote in message
    news:cji0gu$fpt$00$1@news.t-online.com...
    > I have a java class and a second file which contains some binary data
    (assume a zip archive or a gif picture).
    >
    > At the moment when I compile the class I would like to include this file
    into a variable of this class.
    > I think of a variable declaration like:
    >
    > byte[] mybinaryfile = <include dummy.zip>
    >
    > How can I implement this idea?
    > Remember again: I don't want to load this file at runtime but this file
    should be
    > internal part of the one and only java class.
    >
    > Tobias
    >


  • Next message: Mike B: "Re: Creating a .jar package file"

    Relevant Pages

    • Re: How to find the JAR file from which a ava class and all successors had been loaded.
      ... of the JAR file from which a java class (and all subsequent classes which are used in this java class) had been loaded by the classloader. ... The OP wants to get the name of the JAR file from which a resource came, not the name of the resource, assuming the resource came from a JAR, given the resource. ...
      (comp.lang.java.programmer)
    • Re: Pros/Cons Kde vs Gnome?
      ... The resource ... Just let me have a top level dot file in my home ... Perhaps this can be taken care of at compile time, ... the time to hassle with that. ...
      (Debian-User)
    • Re: VS2005 ArgumentException with GetString
      ... Resource file format has changed with VS2005 so make sure your original resx ... went through the upgrade wizard and not just added: ... autogenerated for you giving you compile time checking of ...
      (microsoft.public.dotnet.framework.compactframework)
    • Re: Use of resource images
      ... I made sure to set the set the Build Option of the images to 'Embedded ... If you are using VB 2005/2008, you can access the resource via ... access to resources is bound at compile time and thus type-checked. ... M S Herfried K. Wagner ...
      (microsoft.public.dotnet.languages.vb)