Loading images in a signed jar

Hi,
I am trying to run an application using signed jars.
One of the jars contains gif and jpeg files (icons).
When I sign icons.jar and try to run the code (from
the command line), I get the error listed below.
Any help would be greayly appreciated.
Thanks
Charles
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x76136B9
Function=JNI_OnLoad+0x24D
Library=C:\j2sdk1.4.2_02\jre\bin\jpeg.dll
Current Java thread:
     at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
     at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:144)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:254)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Dynamic libraries:
0x00400000 - 0x00407000      C:\j2sdk1.4.2_02\bin\javaw.exe
0x77F50000 - 0x77FF6000      C:\WINDOWS\System32\ntdll.dll
0x77E60000 - 0x77F45000      C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E5B000      C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x7806E000      C:\WINDOWS\system32\RPCRT4.dll
0x77D40000 - 0x77DC6000      C:\WINDOWS\system32\USER32.dll
0x77C70000 - 0x77CB0000      C:\WINDOWS\system32\GDI32.dll
0x77C10000 - 0x77C63000      C:\WINDOWS\system32\MSVCRT.dll
0x08000000 - 0x08138000      C:\j2sdk1.4.2_02\jre\bin\client\jvm.dll
0x76B40000 - 0x76B6C000      C:\WINDOWS\System32\WINMM.dll
0x10000000 - 0x10007000      C:\j2sdk1.4.2_02\jre\bin\hpi.dll
0x00820000 - 0x0082E000      C:\j2sdk1.4.2_02\jre\bin\verify.dll
0x00830000 - 0x00849000      C:\j2sdk1.4.2_02\jre\bin\java.dll
0x00850000 - 0x0085D000      C:\j2sdk1.4.2_02\jre\bin\zip.dll
0x03240000 - 0x0334F000      C:\j2sdk1.4.2_02\jre\bin\awt.dll
0x73000000 - 0x73023000      C:\WINDOWS\System32\WINSPOOL.DRV
0x76390000 - 0x763AA000      C:\WINDOWS\System32\IMM32.dll
0x771B0000 - 0x772C0000      C:\WINDOWS\system32\ole32.dll
0x5AD70000 - 0x5ADA4000      C:\WINDOWS\system32\uxtheme.dll
0x033C0000 - 0x03410000      C:\j2sdk1.4.2_02\jre\bin\fontmanager.dll
0x73760000 - 0x737A5000      C:\WINDOWS\System32\ddraw.dll
0x73BC0000 - 0x73BC6000      C:\WINDOWS\System32\DCIMAN32.dll
0x73940000 - 0x73A07000      C:\WINDOWS\System32\D3DIM700.DLL
0x07610000 - 0x0762E000      C:\j2sdk1.4.2_02\jre\bin\jpeg.dll
0x76C90000 - 0x76CB2000      C:\WINDOWS\system32\imagehlp.dll
0x6D510000 - 0x6D58C000      C:\WINDOWS\system32\DBGHELP.dll
0x77C00000 - 0x77C07000      C:\WINDOWS\system32\VERSION.dll
0x76BF0000 - 0x76BFB000      C:\WINDOWS\System32\PSAPI.DLL
Heap at VM Abort:
Heap
def new generation total 576K, used 571K [0x10010000, 0x100b0000, 0x104f0000)
eden space 512K, 99% used [0x10010000, 0x1008ecb8, 0x10090000)
from space 64K, 99% used [0x100a0000, 0x100afff8, 0x100b0000)
to space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000)
tenured generation total 1784K, used 1163K [0x104f0000, 0x106ae000, 0x14010000)
the space 1784K, 65% used [0x104f0000, 0x10612c28, 0x10612e00, 0x106ae000)
compacting perm gen total 6912K, used 6759K [0x14010000, 0x146d0000, 0x18010000)
the space 6912K, 97% used [0x14010000, 0x146a9c48, 0x146a9e00, 0x146d0000)
Local Time = Sun Oct 26 16:26:58 2003
Elapsed Time = 10
# The exception above was detected in native code outside the VM
# Java VM: Java HotSpot(TM) Client VM (1.4.2_02-b03 mixed mode)
# An error report file has been saved as hs_err_pid3068.log.
# Please refer to the file for further information.
Corrupt JPEG data: bad Huffman code

http://developer.java.sun.com/developer/bugParade/bugs/4675817.html
You must try using WinZip & not compressing the jpeg's.

Similar Messages

  • Loading images from jar file

    i use the instruction below to load image contained in my jar file for distribution application but the image doesn't appear
    icon = new ImageIcon("images/logo_tunisiana.GIF");
    the jar file contain the image under a subdirectory called images.
    Witch code sample have i to use ?
    thanks in advance

    I have an applet that is packaged in a jar file with images. I can access the images using:
    aIcon = new ImageIcon(KeyboardApplet.class.getResource("images/keyimages/a.jpg"));

  • URLClassLoader + dynamically loading signed jar files

    I have an applet that does not know all of the jar files it will need to load at startup.
    I would like to dynamically load these signed jar files using the URLClassLoader, however it does not recognize these jar files as being signed and I get java.security.AccessControlException: access denied errors.
    Any suggestions?
    Thanks!

    Try this classloader for loading the jars, it should to the trick:
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.net.URLStreamHandlerFactory;
    import java.security.AllPermission;
    import java.security.CodeSource;
    import java.security.PermissionCollection;
    import java.security.Permissions;
    public class AllPermissionsClassLoader extends URLClassLoader {
        public AllPermissionsClassLoader (URL[] urls) {
            super(urls);
        public AllPermissionsClassLoader (URL[] urls, ClassLoader parent) {
            super(urls, parent);
            System.out.println(parent);
        public AllPermissionsClassLoader (URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
            super(urls, parent, factory);
        protected PermissionCollection getPermissions (CodeSource codesource) {
            Permissions permissions = new Permissions();
            permissions.add(new AllPermission());
            return permissions;
    }

  • Problem loading image from jar file referenced by jar file

    First, I searched this one and no, I didn't find an answer. Loading images from jar files has been pretty much done to death but my problem is different. Please read on.
    I have my application, a straight up executable running from Eclipse. It uses a jar file, call it JarA. JarA launches a GUI that is located in another jar file. Call it JarB. To recap:
    My application calls JarA -> JarA loads classes from JarB -> JarB looks for images to place in a GUI it wants to show on the screen
    When JarB goes to load an image the following happens:
    java.lang.NullPointerException
         at sun.misc.URLClassPath$3.run(URLClassPath.java:316)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:313)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:290)
         at sun.misc.URLClassPath.findResource(URLClassPath.java:141)
         at java.net.URLClassLoader$2.run(URLClassLoader.java:362)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findResource(URLClassLoader.java:359)
         at java.lang.ClassLoader.getResource(ClassLoader.java:977)
         at org.cubrc.gmshell.gui.MainWin.preInit(MainWin.java:152)
         at org.cubrc.gmshell.gui.MainWin.<init>(MainWin.java:135)
    The code from JarB that loads the image looks like this:
              URL[] oSearch = {Main.class.getResource("images/")};
              URLClassLoader oLoader = new URLClassLoader(oSearch);
              imgIcon = new ImageIcon(oLoader.getResource("icon.gif"));
              imgMatchRunning = new ImageIcon(oLoader.getResource("gears.gif"));
              imgMatchStill = new ImageIcon(oLoader.getResource("gears-still.gif"));
              imgMagnify = new ImageIcon(oLoader.getResource("magnify.gif"));This looks right to me and JarB certainly has an images directory with those files. But I'm in hell right now because I don't know where to place the images to make this work or if you can even attempt to load images with a dependency chain like this.
    Any help very appreciated!

    Have you tried to move your image-files out of the jar file and place them in the sam folder as the jar-file? I think that would help.
    When you try to load the image-file you get the NullPointerException because the program tries to read a file it can't find. Remember that a jar file IS a file and not a directory.
    If you want to read somthing inside the jar-file you need to encode it first.
    Have you tried to read the jar-file with winRar. It makes it easy to add and remove files in your jar-file.

  • Loading images from jar

    Found a good solution that works from running in command line, i.e java -jar or normally or using web start and not getting missing image URL loading from jar
    It deserves some dukes :) Also, someone can improve on it to make sure it's 100%
    Asume the function is in a package AWTUtilities class
    Many forums provide close solution but they all forget the vital replacing back slash with forward slash when reading from jar!! :)
    That's what got me stump for a good day trying to figure why it should load the images, but it's not...
    Regards
    Abraham Khalil
       // The subtlety in getResource() is that it uses the
       // Class loader of the class used to get the rousource.
       // This means that if you want to load a resource from
       // your JAR file, then you better use a class in the
       // JAR file.
       public static Image getImageResource( String name ) throws java.io.IOException {
          return getImageResource( AWTUtilities.class, name );
       public static Image getImageResource(Class base, String name ) throws java.io.IOException {
          if (name != null) {
             Image result = null;
             // A must, else won't pick the path properly within the jar!!
             // For file system forward or backward slash is not an issue
             name = name.replace('\\', '/');
             // For loading from file system using getResource via base class
             URL imageURL = base.getResource( name );
             // For loading from jar starting from root path using getResource via base class
             if (imageURL == null) {
                imageURL = base.getResource("/" + name );
             // For loading from file system using getSystemResource
             if (imageURL == null) {
                imageURL = ClassLoader.getSystemResource( name );
             // For loading from jar starting from root path using getSystemResource
             if (imageURL == null) {
                imageURL = ClassLoader.getSystemResource("/" + name );
             // Found the image url? If so, create the image and return it...
             if ( imageURL != null ) {
                Toolkit tk = Toolkit.getDefaultToolkit();
                result = tk.createImage( (ImageProducer) imageURL.getContent() );
             return result;
          else {
             return null;

    The problem is that you use the wrong classloader. The system default classloader is the one that launched the webstart utility. It doesn't contain your classes or jars. You have to get hold of the classloader for your classes.
    Here's my solution as a schetch: probably it won't compile but you get the idea:
    // 1: get hold of the classloader for my classes:
    // - this class cannot possibly be loaded by anyone else:
    Object dummy = new Object(){
    public String toString() { return super.toString(); }
    ClassLoader cl = dummy.getClass().getClassLoader();
    // 2: get an inputstream to read resource from from jar:
    InputStream is = cl.getResourceAsStream("images/myimage.gif");
    // 3: create image from inputstream
    // can be done in many different ways using tmp-files etc.
    ImageIcon icon = new ImageIcon(is);
    Image img = icon.getImage();

  • Loading images inside applet JAR

    Hi
    This is my issue: I have an applet which contains images inside the applet JAR. I want to display these images in my applet, but apparently due to browser access restrictions, I'm not allowed.
    My first code was like this:
    //security restrictions on browsers do not allow getResource
    ImageIO.read(MyClass.class.getResource("imgs/img.png"));
    //getResourceAsStream should be allowed by browsers
    ImageIO.read(MyClass.class.getResourceAsStream("imgs/img.png"));Both lines work when I execute the applet locally (command line / programming IDE), but when I deploy it to my web server, the resource "imgs/img.png" becomes a relative URL to my web application context (like /webcontext/MyClass/imgs/img.png). It works locally because the call to getResource returns a URL object with "file:" protocol, but I need it to look for my images bundled inside the JAR, not web hosted images.
    I need to avoid making the applet look for these images as a web resource... how can I do it?
    Thanks!

    dev@java wrote:
    warnerja wrote:
    I'm not convinced the code you posted wouldn't work, but since this is an applet, you have access to the Applet class. Check out the Applet.getImage method in conjunction with Applet.getCodeBase.
    [http://java.sun.com/javase/6/docs/api/java/applet/Applet.html]
    getCodeBase returns my web context, like http://myhost.com/mycontext/ , so it is pretty much the same as above.
    Thanks for your replyThat is the way to load resources though. Hence back to my earlier statement about not being convinced it would not work, with this addition: It should work, assuming you actually do have the resources properly located with the web app, whether they be in a jar, or loose files relative to where the web app is. My guess at this point is that they are not.

  • Poblem with FXML to load image in jar using: Image url="@/myImage.png"/

    If my FXML und image files are in a JAR-file then I have the Exception:
    Caused by: java.lang.IllegalArgumentException: URL must not be empty
    at javafx.scene.image.Image.validateUrl(Image.java:966)
    at javafx.scene.image.Image.<init>(Image.java:611)
    at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:27)
    My FXML file:
    <Button>
    <graphic>
    <ImageView>
    <image>
    <Image url="@/images/Printer_48.png" />
    </image>
    </ImageView>
    </graphic>
    </Button>
    Is there a Problem with the JavaFXImageBuilder which can't not load Images in JAR files?

    In jars it is case-sensitive:
    <Image url="@/images/myImage.png"/>
    is not the same as
    <Image url="@/images/myImage.PNG"/>
    Edited by: 961538 on Sep 27, 2012 4:03 AM

  • Loading image from jars only once in oracle forms 10g

    Hi,
    I have an oracle forms 10g application which loads image from a jar. Every time i click on a button "A" that loads the image "image" on another button "B" in the same screen, a message is displayed in the java console "Loaded image: jar:https://+IP+/forms/java/+myjar+.jar!/image.gif". So after 10 clicks, i get the same message displayed 10 times. In the form, i've called:
    SET_CUSTOM_PROPERTY(p_object_name, 1, 'IMAGE_NAME_ON', '/'||p_image_name);My question is the following:
    - is there a way to load this image once and use it later without having to load it every time i clik on "A"? if yes, how?
    P.S.: if this thread shouldn't be posted in this forum, please redirect me to the right one.
    Thanks in advance

    Ah okay.
    I'm using the rolloverbutton.jar (RollOver Button PJC) [RolloverButton.java -> authors: Steve Button, Duncan Mills].
    Here is the part concerning the IMAGE_NAME_ON function:
    // make sure we are in rollover mode
    enableRollover();
    log("setProperty - IMAGE_NAME_ON value=" + value.toString());
    // load the requested image
    m_imageNameOn = (String) value;
    loadImage(ON,m_imageNameOn);
    // reset the currrently drawn image if needed
    setImage(ON,m_state);
    return true;where loadImage function is:
        URL imageURL = null;
        boolean loadSuccess = false;
        //JAR
        log("Searching JAR for " + imageName);
        imageURL = getClass().getResource(imageName);
        if (imageURL != null)
          log("URL: " + imageURL.toString());
          try
            m_images[which] = Toolkit.getDefaultToolkit().getImage(imageURL);
            loadSuccess = true;
            log("Image found: " + imageURL.toString());
          catch (Exception ilex)
            log("Error loading image from JAR: " + ilex.toString());
        else
          log("Unable to find " + imageName + " in JAR");
        //DOCBASE
        if (loadSuccess == false)
          log("Searching docbase for " + imageName);
          try
            if (imageName.toLowerCase().startsWith("http://")||imageName.toLowerCase().startsWith("https://"))
              imageURL = new URL(imageName);
            else
              imageURL = new URL(m_codeBase.getProtocol() + "://" + m_codeBase.getHost() + ":" + m_codeBase.getPort() + imageName);
            log("Constructed URL: " + imageURL.toString());
            try
              m_images[which] = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              log("Image found: " + imageURL.toString());
            catch (Exception ilex)
              log("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            log("Error creating URL - " + urlex.toString());
        //CODEBASE
        if (loadSuccess == false)
          log("Searching codebase for " + imageName);
          try
            imageURL = new URL(m_codeBase, imageName);
            log("Constructed URL: " + imageURL.toString());
            try
              m_images[which] = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              log("Image found: " + imageURL.toString());
            catch (Exception ilex)
                    log("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            log("Error creating URL - " + urlex.toString());
        if (loadSuccess == false)
          log("Error image " + imageName + " could not be located");In this case, what shall i modify?
    Thanks in advance

  • Issues with Loading Images from a Jar File

    This code snippet basically loops through a jar of gifs and loads them into a hashmap to be used later. The images all load into the HashMap just fine, I tested and made sure their widths and heights were changing as well as the buffer size from gif to gif. The problem comes in when some of the images are loaded to be painted they are incomplete it looks as though part of the image came through but not all of it, while other images look just fine. The old way in which we loaded the graphics didn't involve getting them from a jar file. My question is, is this a common problem with loading images from a jar from an applet? For a while I had tried to approach the problem by getting the URL of the image in a jar and passing that into the toolkit and creating the image that way, I was unsuccessful in getting that to work.
    //app is the Japplet
    MediaTracker tracker = new MediaTracker(app);
    //jf represents the jar file obj, enum for looping through jar entries
    Enumeration e = jf.entries();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    //buffer for reading image stream
    byte buffer [];
    while(e.hasMoreElements())
    fileName = e.nextElement().toString();
    InputStream inputstream = jf.getInputStream(jf.getEntry(fileName));
    buffer = new byte[inputstream.available()];
    inputstream.read(buffer);
    currentIm = toolkit.createImage(buffer);
    tracker.addImage(currentIm, 0);
    tracker.waitForAll();
    images.put(fileName.substring(0, fileName.indexOf(".")), currentIm);
    } //while
    }//try
    catch(Exception e)
    e.printStackTrace();
    }

    compressed files are not the problem. It is just the problem of the read not returning all the bytes. Here is a working implementation:
    InputStream is = jar.getInputStream(entry);
    ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
    try{
    byte[] buf = new byte[1024];
    int read;
    while((read = is.read(buf)) > 0) {
    os.write(buf, 0, read);
    catch(Exception e){
         e.printStackTrace();
         return null;
    image = Toolkit.getDefaultToolkit().createImage(os.toByteArray());
    This works but I think you end up opening the jar a second time and downloading it from the server again. Another way of getting the images is using the class loader:
    InputStream is = MyApplet.class.getResourceAsStream(strImageName);
    In this case, the image file needs to be at the same level than MyApplet.class but you don't get the benefit of enumerating of the images available in the jar.

  • Images not loading when I run my JAR

    I created a Yahtzee game that contains five die images. When I created the JAR file, I explicitly added the source and images to it. But when I go to run the app, no die images show up. I referenced Java's Creating a JAR File tutorial (http://java.sun.com/docs/books/tutorial/deployment/jar/build.html) but I didn't find anything useful regarding my issue.
    My Images folder is under my classes folder: Yahtzee\build\classes\Images
    I create the JAR from within classes and I add the die images that are in Images by using change directory option -C.
    jar cvfm Yahtzee.jar Manifest.txt *.class -C Images/ .
    I'm using the verbose option v, which allows me to see every file that gets added to the JAR, so I know there's no problem with missing files.
    Any thoughts?
    Message was edited by:
    d_mart

    By the way I'm adding the images into the JAR, they should be in its root.
    This is what I'm doing with my code. I have five die buttons that get a random die face, which are represented with my die images. I have an up-state (unselected) and a down-state (selected) image for each die face (1, 2, 3, 4, 5, 6). I have two different states because just like poker, you keep the cards that you want and disgard the ones that you don't want and in return, you get some random card for every card that you disgarded. So the selected and unselected images should be self-explanitory now. In Yahtzee, you have up to three rolls per hand, which I have a button that handles the rolls (<=3). I have stored my die images in a 2D array.
    My image file names are as follows:
    d1up.png, d1down.png, d2up.png, d2down.png,...d6up.png, d6down.png
    private Icon [][] dieImages;
    private Icon defaultDieImage;
    private Die [] dieButtons;
    // INITIALIZE DIE IMAGES
    defaultDieImage = new ImageIcon("../Yahtzee/src/Images/blank.png");
    dieImages = new ImageIcon[2][6];
    for(int i = 0; i <= 5; i++) {
         // up state images
         dieImages[0] = new ImageIcon("../Yahtzee/src/Images/d"
    + (i + 1) + "up.png");
    // down state images
    dieImages[1][i] = new ImageIcon("../Yahtzee/src/Images/d"
    + (i + 1) + "down.png");
    Those images are then loaded into the die buttons (depending on the roll).
    FYI, I just finished my 2nd semester of Java, so I'm still pretty new to the language and it's the only language that I know so far. With that said, please forgive for any dumb mistakes. It's all good though, I learn something new everyday. So you say that I should be using something like getClass().getClassLoader().getResource("an_image.jpg"); in my code instead of what I have?
    I hope the information that I provided helps.
    Dan

  • PJC - Loading Images from JAR Files

    I'm developing a PJC class that involves loading images. I would like to be able to find and use an image contained in a JAR file just like the built-in Forms items do; not the JAR file where my class is contained but any external ones defined in the server archive settings.
    I have seen the loadImage method in the demo RolloverButton class but this only loads images from the class's JAR and not any others.
    Is there a VButton method or an Oracle loader class for finding image resources from the defined JAR archives? If not, could someone supply some code for achieving this.
    Thank you.

    Hi,
    the jar file name the images are in shouldn't matter for the code as long as the package name is preserved. If you want to see it with your own eyes, do the following
    1. Back up demo90.jar
    2. Create a copy of it and call it demo90img.jar
    3. Open demo90.jar in winzip and remove all images
    4. Open demo90img.jar and remove all Java classes
    5. add ,/forms90demo/jars/demo90img.jar to the archive_jini tag of a demo you want to test this on
    6. Run the application and see the images despite the fact they are now in a separate jar file. Note in the Jinitiator console that the new jar files are downloaded and replace the existing, cached, jars
    7. Run an application that doesn't have demo90img.jar configured to see that the images are missing.
    Frank

  • Loading images from Jar - Please help!

    Tried with / in front of the path or without and using both
    getImageResource and getSystemImageResource methods and no images
    are showing.
    My jar has manifest file of:
    Main-Class: com.package.MainFrame
    Class-Path: j2ee.jar
    - blank line -
    Thanks
    Abraham Khalil
       // The subtlety in getResource() is that it uses the
       // Class loader of the class used to get the rousource.
       // This means that if you want to load a resource from
       // your JAR file, then you better use a class in the
       // JAR file.
       public static Image getImageResource( String name ) throws java.io.IOException {
          return getImageResource( AWTUtilities.class, name );
       public static Image getImageResource(Class base, String name ) throws java.io.IOException {
          Image result = null;
          URL imageURL = base.getResource( name );
          if (imageURL == null) {
             imageURL = base.getResource("/" + name );
          System.out.println("imageURL: " + imageURL + " AWTUtilities.class.getResource(" + name + ");");     
          if ( imageURL != null ) {
             Toolkit tk = Toolkit.getDefaultToolkit();
             result = tk.createImage( (ImageProducer) imageURL.getContent() );
          return result;
       public static Image getSystemImageResource( String name ) throws java.io.IOException {
          Image result = null;
          URL imageURL = ClassLoader.getSystemResource( name );
          if (imageURL == null) {
             imageURL = ClassLoader.getSystemResource("/" + name );
          System.out.println("imageURL: " + imageURL + " = ClassLoader.getSystemResource(" + name + ");");
          if ( imageURL != null ) {
             Toolkit tk = Toolkit.getDefaultToolkit();
             result = tk.createImage( (ImageProducer) imageURL.getContent() );
          return result;

    Hello,
    you must put your images files under your package :
    see full doc at this tutorial.
    Hope this helps,
    Neo

  • Loading an image present  in a JAR through an applet

    We are mgirating from MS JVM to SUN JVM.We are facing problems with loading bitmaps present in a Jar file.
    Here is the code snippet..
    iActive= Util.mgrlistApplet.getImage(Util.mgrlistApplet.getDocumentBase(), activeImage);
    Util is an user defined class.
    activeImage is the image file name.
    The above code works in MS JVM
    Thanks in advance.

    Try something like this:
    java.net.URL url = getClass().getResource("/images/progbar.gif");
    ImageIcon icon = new ImageIcon(url);
    JLabel label = new JLabel(icon);
    This will get the image progbar.gif will be relative to the root of the jar file and from the images directory. If you want to get it relative to the class that you are working in remove the / at the beginning.
    Chris

  • Problem loading images in my applet

    Hi guys,
    When i test my Applet using an IDE the images are loaded fine, however when I run my applet using a browser it wont load the images.
    I think it is because I use this line:
    System.getProperty("java.class.path",".")My question is, how do you load images into an applet without signing it.
    Any help would be great.
    Alex

    Axilliary files like images, properties files etc. which are essentially part of the program are refered to as "resources". The best way to access these files is by the getResource() methods in the Class or ClassLoader objects. If you do it that way then the JVM reads them exactly the same way it reads .class and from the same place.
    Say your using an image, say my.gif from a class called MyClass. You put the image file in the same directory as the MyClass.class file. Then, in MyClass, you do:
    static ImageIcon myImage = new ImageIcon(MyClass.class.getResource("my.gif"), "MY Image");That will pick up the image from a file, from an http connection, from a jar, of from any combination of same.

  • Signed Jars

    I have a web based project that includes numerous iamges. As a result of the images I must sign the jar files. However, to date I have been unsuccessful. I have reviewed the threads and deployment information and would appreciate a straightforward way to accomplish this with Net Beans (the signing function there has not worked for me as well). I would appreciate any assistance.

    If you can place the images inside your jar file and load them from there or place them on a server that hosts crossdomain.xml (*exactly* this file http://static.flickr.com/crossdomain.xml) in the root directory of it's domain, then you do not need to sign your jar file. If you cannot do either of these things and the images must be hosted on a different server than the one hosting your jars, then read on.
    Do not try to use the javafxpackager command line tool to sign jars as that does not currently work => this issue can be tracked here: http://javafx-jira.kenai.com/browse/RT-18246
    Signing documentation is here =>
    http://docs.oracle.com/javafx/2.0/deployment/packaging.htm#BABJGFBH
    http://docs.oracle.com/javafx/2.0/deployment/javafx_ant_task_reference001.htm#CIAFJGAB
    But you have already read all that.
    Signing requires the following steps.
    1. Generate a Certificate Signing Request (CSR).
    2. Submit the CSR to a Certificate Authority (CA).
    3. The CA will generate a code signing certificate for you.
    4. Package your application as a bunch of jar files.
    5. Sign the jar files using your code signing certificate.
    If you are just using a self signed certificate and you are already using NetBeans, then NetBeans can do all of this for you.
    Here are the steps I used to sign a JavaFX project consisting of multiple Jar files using NetBeans nightly build 201112120600
    1. Right click Project and choose Properties.
    2. Project Properties | Libraries | Compile |Add Library... and add your dependent jars.
    3. Project Properties | Packaging
    Check Compress JAR File
    Check Build JAR after Compiling
    Check Copy Dependent Libraries
    Do not check Binary Encode JavaFX CSS Files as that might be buggy.
    4. Project Properties | Deployment
    Check Request unrestricted access
    Signing Certificate: Edit...
    a) choose Self-signed by a generated key OR
    b) use your own keystore if you have a certificate from a trusted public CA.
    Download Mode for Libraries: Use the mix of eager and lazy appropriate for your app. Signing wise, it doesn't matter as all of the jars need to be signed anyway.
    5. Project Properties | Run
    Configuration | New... | Configuration Name => enter browser
    Application Class | Browse... choose your Application's main class.
    Check Use Preloader if you have one (the preloader jar will be signed). If you are having difficulties with basic signing, get that to work first before enabling the Preloader.
    Select Run | in Browser
    Set a Width and Height for the page.
    Leave Web Page empty until you get an empty web page with your app in it to work.
    Choose the Web Browser you want to launch the app in.
    Press OK.
    6. Select the browser config from the drop down combo and hit the run arrow.
    Netbeans will compile your app, package it, generate a self signed certificate, sign all of your application's jars and launch the application in a browser.
    A trick to getting all of the above to work more than one time, is to make sure that you close the browser tab after you have finished testing and before you try to run again, otherwise NetBeans seems to fail with weird errors because the distribution files get locked by the app running inside the browser under Windows.
    If you are still stuck, you can try opening this JavaFX project which uses self-signed jars in NetBeans 7.1 RC2 or later => http://willow-browser.googlecode.com/files/willow-src-prerelease-0.1-netbeans-project.zip

Maybe you are looking for