GIFs in package resources in JAR

Hello all,
I am deploying a java GUI with resource GIFS in a JAR.
While I am developing in the IDE (Eclipse) everything works out fine: the resource GIFS are loaded from the package resources and are displayed in the GUI.
Then I distribute a JAR using Ant: see manifest.mf at the end of the text.
When I deploy the application now, no resource GIFS are displayed on the GUI. This behaviour changes non-deterministically.
Error could be the packaging into JAR or display of the GUI?
Thank you in advance,
Gerrit Leder
-----------------------------------------------------------------manifest.mf:
Manifest-Version: 1.0
Created-By: 1.5.0_09 (Sun Microsystems Inc.)
Main-Class: vci/VciManagement
Class-Path: .

When I loaded the Image with getImage(...) I used checkImage(...):
In the IDE the Result was 0.
Then I loaded the Image with getImage(...) and used prepareImage(...) and then checkImage(....):
In the IDE the result was 7 then 39.
In the Jar the result was 64.
What is the int code representing?
Here is my code now:
class ViewComponent extends JComponent
     private Image image;
     private int iResult;//checkImage: Result
     private boolean bResult;//prepareImage: Result
     protected void paintComponent( Graphics g )
          // Dimension size = this.getSize();
          this.setLocation(35,0);
          if (image.getWidth(this) <= 0 ){
               this.setSize(16,16);
          } else {
               this.setSize(image.getWidth( this), image.getHeight(this ) );
          if ( image != null ){
               g.drawImage( image, 0, 0, this );
               // System.out.println( "paintComponent: width = " + image.getWidth( this) + ", height = " + image.getHeight(this ) );
     public void setImage( String filename )
          image = Toolkit.getDefaultToolkit().getImage( filename );
          System.out.println( "filename >" + filename + "<: width = " + image.getWidth( this) + ", height = " + image.getHeight(this ) );
          if ( image != null )
               bResult=prepareImage(image,
                    image.getWidth(this),
                    image.getHeight(this),
                    this);
               iResult=checkImage(image,
                    image.getWidth(this),
                    image.getHeight(this),
                    this);
          System.out.println("BEFORE repaint(), checkImage Result: " + Integer.toString(iResult));
               repaint();
               iResult=checkImage(image,
                    image.getWidth(this),
                    image.getHeight(this),
                    this);
          System.out.println("AFTER repaint(), checkImage Result: " + Integer.toString(iResult));
}

Similar Messages

  • Loading resources from jar - problem

    I've got a problem when loading resources from jar.
    My code:
    package game.player;
    import javax.swing.ImageIcon;
    import java.awt.Image;
    import game.map.Map;
    import game.map.MapReader;
    import game.emptyclass.EmptyClass;
    import java.net.URL;
    public class Data
        ClassLoader cl = EmptyClass.class.getClassLoader();
        Image image1 = new ImageIcon(cl.getResource("data/sprites/man6.png")).getImage();
        Image image2 = new ImageIcon(cl.getResource("data/sprites/man5.png")).getImage();
        Image image3 = new ImageIcon(cl.getResource("data/sprites/man4.png")).getImage();
        Image image4 = new ImageIcon(cl.getResource("data/sprites/man3.png")).getImage();
        Image image5 = new ImageIcon(cl.getResource("data/sprites/man2.png")).getImage();
        Image image6 = new ImageIcon(cl.getResource("data/sprites/man1.png")).getImage();
        public Image tile1 = new ImageIcon(cl.getResource("data/maps/test/tile1.png")).getImage();
        public Image bg = new ImageIcon(cl.getResource("data/maps/default/bg.png")).getImage();
        public Map map = new MapReader(cl.getResource("data/maps/test/test.map").getPath()).getMap();
        public int getImageWidth()
            return image1.getWidth(null);
        public int getImageHeight()
            return image1.getHeight(null);
    }I get a NullPointerException.
    Thanks in advance!

    Hi ,
    getResource() method argument is not begin with the
    character '/' , ex.
    Image image1 = new
    ImageIcon(cl.getResource("/data/sprites/man6.png")).ge
    tImage();
    I thought of that, but it's not applicable here because getResource is being called on the ClassLoader, not the Class.

  • Cant view package contents in .jar file Mac OS X

    I understand that I should be able to right-click on a .jar file to get a number of options, one of which is 'show package contents'.
    I have created a .jar file of my project, but when I right-click, no such option appears, so I can't see what's inside.
    Any suggestions?
    Also, is there a better way to view and edit the package contents, in particular the manifest file?

    Martin_J wrote:
    I understand that I should be able to right-click on a .jar file to get a number of options, one of which is 'show package contents'.
    I think you may be confused between the jar file, and the application bundle on OS X. When you hold down the ctrl key and then left click, normal click on an application bundle file, you do indeed see a number of options. One of which is to show package contents. An application bundle is a form of a directory and showing the package contents allows you to navigate the directory of the bundle on OSX.
    I have created a .jar file of my project, but when I right-click, no such option appears, so I can't see what's inside.
    Correct. Neither can I. I've not heard of right clicking on jar files to see inside.
    Any suggestions?
    Also, is there a better way to view and edit the package contents, in particular the manifest file?The manifest file is part of the jar file. The application bundle is assembled from, among other resources, the jar files that make up your application.

  • Trying to use ord.jdom package with a jar - it's not working...

    Guys, I'm trying to build a Swing app that uses jdom classes and interfaces. I built the app in NetBeans, and to get the jdom packages to work, I had to mount the jdom.jar. Then suddenly, I had no errors using the jdom classes Document, Element, SAXBuilder etc. I have the program running perfectly inside the netbeans interface.
    Now, how do I get everything working together in a JAR?
    Here's the starts of the respective files:
    * CTATool.java
    * Created on January 3, 2004, 1:23 PM
    package CTATool;
    * @author  jason_michael_trk
    public class CTATool extends javax.swing.JFrame
        /** Creates new form CTATool */
        public CTATool()
            initComponents();...
    * FileWriterXML.java
    * Created on March 5, 2004, 10:06 AM
    package CTATool;
    import org.jdom.*;
    import org.jdom.output.*;
    import java.io.*;
    * @author  Jason L Michael
    public class FileWriterXML
        private Document doc;
        private FileWriter fw;
        private File f;
    I need to include in the JAR the org.jdom package. How do I do this?
    Here's the manifest I am using cirrently:
    Manifest-Version: 1.0
    Created-By: NetBeans IDE
    Specified-By: CTATool.V2.jarContent
    Main-Class: CTATool.CTAToolThe jar includes the CTATool.class file, the FileWriterXML.class file and the jdom.jar.
    I'm getting the following errors, when I attempt to execute the CTATool.V2.jar:
    java.lang.NoClassDefFoundError: org/jdom/JDOMException
            at CTATool.CTATool.saveStatsAndExit(CTATool.java:1457)
            at CTATool.CTATool.quitMenuItemActionPerformed(CTATool.java:1450)
            at CTATool.CTATool.access$400(CTATool.java:13)
            at CTATool.CTATool$5.actionPerformed(CTATool.java:157)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
            at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
            at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
            at java.awt.Component.processMouseEvent(Component.java:5134)
            at java.awt.Component.processEvent(Component.java:4931)
            at java.awt.Container.processEvent(Container.java:1566)
            at java.awt.Component.dispatchEventImpl(Component.java:3639)
            at java.awt.Container.dispatchEventImpl(Container.java:1623)
            at java.awt.Component.dispatchEvent(Component.java:3480)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
            at java.awt.Container.dispatchEventImpl(Container.java:1609)
            at java.awt.Window.dispatchEventImpl(Window.java:1590)
            at java.awt.Component.dispatchEvent(Component.java:3480)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)this is right when the FileWriterXML class is created and ran.
    Help??!??Thanks in advance!
    chewy

    I think I figured this out, if it helps anyone...
    You have to wrap up all of YOUR classes into a jar, and have a manifest entry that specifies:
    Class-Path: jdom.jar
    Next, you have to put the two together (I used a self-extracting zip file. It contained MyApp.jar and jdom.jar).
    when the client extracts it onto their desktop and double clicks on MyApp.jar, it works perfectly.
    I don't think there's an easy way to package the jdom.jar in my jar and make this work.
    Hope this helps some other wary traveler!
    chewy

  • Resources inside JAR - problem

    I have a strange problem with resources inside JARs.
    I can't load any resource form a JAR file (for example a .property file or .png icon).
    It's not a problem with my progams only. JDBC drivers doesn't work because they cannot find .properties files while they work well when, the driver JAR i uncompressed. It happens every time when some resouces are inside JAR library (classes are loade correctly). The same project runs well on my friend's computer while I've got an error on my computer.
    I tried it on WinXP and Win2003 Server - the same. My java version 1.5.0_06-b05 (but I had the same problem with older versions).
    I figured out that I can find a file inside a JAR, open a stream, load data and everything is OK but data is always 0bytes length. For example using:
    ImageIcon myImageIcon = new ImageIcon(getClass().getResource(pathandfilename));
    I get empty ImageIcons without any error.
    Can anyone help me. Maybe I should find something somwhere in java configuration.
    Message was edited by:
    peper

    But can anyone tell me why my servlet can not access the
    contents inside a jar file?? Any suggestions please?
    Thanks.Without seeing your code, it is likely that you are trying to use file names (like /some/path/yourFileName.ext), not resource names (loadable from the class loader) like /yourFileName.ext.
    Example:
    Instead of:
    FileInputStream stream = new FileInputStream("/some/path/yourFileName.ext");
    do this:
    InputStream stream = getClass().getResourceAsStream("/yourFileName.ext");
    There are other API's which take either a string file name or a URL. You want to go the URL way, where the URL is taken from the classpath as:
    URL url = getClass().getResource("/yourFileName.ext");

  • DSC Package resource handling EXE (not MSI)

    I am working through using the built-in Package resource provider for Desired State Configuration and I am having issues with using .EXE files with it (not MSI).
    I see no failures in Trace-xDscOperation and I also don't see any attempt at processing the package, nor any errors with the attempt.
    .EXE don't have 'ProductId' as a property (not the GUID that an MSI has) so I am a little confused as to how to set this up properly.
    All of the documented examples are with MSI packages, not EXE.
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

    If you use the Start-DscConfiguration with the -debug switch the script file has very comprehensive debugging enabled. It *should* tell you where things are going wrong. 
    having read through the script a little (you'll find it at C:\Windows\system32\WindowsPowershell\v1.0\Modules\PSDesiredStateConfiguration\DSCResources\MSFT_PackageResource\MSFT_PackageResource.psm1 ) Might help you identify what's going on. 
    But it seems that for an exe the ProductId is used as the identifier for the uninstall directory. so you should be able to use [guid]::NewGuid() to create a new random one and pass that into it. 
    Hope this helps! Let us know how it goes - we're all still learning the quirks of this! 

  • How can I obtain the resources in jar?

    How can I obtain the resources in jar if the class that to want this resource is static?
    I don't succeed use like:
    getClass().getResourceAsStream("/" + name)
    because my class is static.
    Thaks

    You could do this
    new Object().getClass().getResourceAsStream("/" + name)
    or
    Object.class.getResourceAsStream("/" + name)

  • Extracting class files of a certain package from a jar.

    Hi,
    I want to extract all the class files belonging to a certain package from a JAR file containing class files belonging to a different packages.
    Can I do this using the jar tool, or use some other unzipping tool?
    If it is best to use an unzipping tool which one can I use for windows?
    Thanks,
    Niranjan.

    jar xf file.jar path/to/dir
    For more info see http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/jar.html.

  • Need help: how to make a package into a jar file?

    I tried to make a package into a jar file by using:
    jar cf a.jar packagedirectory
    But when I import one class of this package in an other application, by using:
    javac -cp path\a.jar; app.java
    the compliler can not find the calss.
    The interesting thing is if I do not put the package into the jar file, it works well.
    Here is my sample code under path D:\b\b1
    package b1;
    public class Son
         int x = 10;
         public Son(){
         public int getX(){
              return x;
    and the application code under path d:\b
    import b1.Son;
    public class Father
         public Father(){
         public static void main(String[] args)
              Son son = new Son();
              System.out.println("Hello World!"+son.getX());
    Thanks for any advise.
    Xin Cheng

    You must make sure that you are in the right directory
    when you do your jar command to create the archive.
    [home/trejkaz/proj/test/classes]% jar -cf a.jar
    path/to/package/*.class
    Thank you very much.
    Yes, I did as what you said, but it does not work.
    Here is what I did:
    1. Edit Father.java in D:\b
    2. Edit Son.java in D:\b\b1
    3. Compile Son.java
    4. Complie Father.java
    5. Make the a.jar by
    command jar cf a.jar D:\b\b1\ (I cheked the content of the a.jar, it seems right.)
    a.jar is in directory D:\b
    6. Delete Son.class in D:\b\b1
    7. Run Father.class by
    command: java -classpath D:\b\a.jar; Father
    error message is: Exception in thread "main" java.lang.NoClassDefFoundError: b1/Son
    at Father.main(Father.java:11)
    What is the problem?
    Thanks again.

  • My app works in IDE but not when packaged as a JAR, advice please?

    Hello,
    I've written my application which seems to work perfectly in my IDE, however when I package the application into a JAR, the JavaVM isn't happy with it. When executed, the JVM crashes somewhere early in my program (I'm guessing when it's loading resources) and I get a nice crash dialog from my OS describing some low level stuff.
    So my reason for posting is to gather some advice or guidance on how to tackle this. Is there a simple way to debug a program when it's in JAR form?
    Any comments will be welcomed! Thanks.
    CRASH INFO - just in case it's useful!! :)
    EXC_BAD_INSTRUCTON (0x0002)
    0x0000000D
    Thread 0 Crashed:
    0    JVM_RaiseSignal + 595867
    1    JVM_RaiseSignal + 596054
    2    JNI_CreateJavaVM_Impl + 49220
    3    JVM_Write + 18645
    4    callback + 317
    5    0 + 25151061
    6    __CFRunLoopDoObservers + 342
    7    CFRunLoopRunSpecific + 1548
    8    CFRunLoopRunInMode + 61
    9    0x1000 + 14040

    Those links you posted proved very useful. Using OS dumps a log file which points out an offending library. After a bit of googling, I manage to found out that it was coming from the SWT framework which my app is built on. I've written tons of SWT apps before but I've no idea why this one get upset when I run it?
    I've since took the time to compile and run a Windows & Linux version and they both work perfectly.
    Thanks for the help on this and judging my current situation I think it would be best to speak to the Eclipse/SWT people as this problem has gone slightly 'off-topic' :)

  • Using a UNIX shell script to run a Java program (packaged in a JAR)

    Hi,
    I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
    Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
    loggedinuser="$(whoami)"
    CFG_DIR="`dirname $0`"
    EXIT_STATUS=${SUCCESS}
    export PATH=/opt/java1.3/bin:$PATH
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIR
    java -classpath $
    EXIT_STATUS=$?
    cd $OLDDIR
    echo $EXIT_STATUS
    exit $EXIT_STATUS

    Hi,
    I have an application (very small) that connects to
    our database. It needs to run in our UNIX environment
    so I've been working on a shell script to set the
    class path and call the JAR file.
    #!/bin/sh
    exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
    CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
    cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
    echo $EXIT_STATUS
    exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
    Harald.

  • Gif file not found in JAR from Java Application

    Hello Forumers,
    Could some one please explain how to create a JAR file from where I can get a GIF file. I have tried a number of different ways but it allways fails. (I have tried to add the GIF files using the jar command and I have tried to add it using WinZip after the jar is created).
    To isolate the problem I created this very simple program, the program works very well when the gif file resides on the directory from where I run the Application, but when I remove it from the directory it fails. I have tried to put the GIF file in the JAR in a number of different ways but it allways fails. (I have also tried with and without slash before the name of the GIF). I guess the problem is the way I create the JAR file
    import java.io.*;
    public class GifTest
    { public static void main(String args[])
    { InputStream in = GifTest.class.getResourceAsStream("/open.gif");
    if (in==null)
    System.out.println("Null returned");
    else
    System.out.println("OK");
    Any Hints appreciated
    /Kjell

    Hi,
    here is a small application using my own class GetImageIcon.
    Normally I have this "help-class" in a utility-package to use it from all my projects without copying. For this example I copied the code in the test application. Feel free to use the code of the class like you want. For me it works fine.
    Do the following:
    1. Create a folder called /meta-inf under the folder where the class-files are. Use a text-editor and create a file saved as "manifest.mf".
    manifest.mf tells the jar-file which is the main-class from where the application will start when double-clicked.
    It only has to contain one line:
    Main-Class: GifTest
    2. Compile and create the jar file. I made a bat-file containing:
    javac -verbose GifTest.java
    %pause
    REM Create Jar-File
    jar cmf meta-inf/manifest.mf GifTest.jar *.class *.gif
    REM Show Table of Content of the Jar-File
    jar tf GifTest.jar
    %pause
    So you can see what's in the jar-file.
    3. When you double-click on the jar-file the application is executed. So it is easier to use for the users. They don't have to type in anything on the command-line. You can deploy this jar-file to any client and run it. The only thing you have to do, is to install the JRE on the clients.
    I develop with JDK 1.3.1 and JRE 1.3.1 is installed on the clients of the company I work for.
    //Begin of the code
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.util.jar.*;
    public class GifTest extends JFrame
            protected JLabel m_title;
            protected ImageIcon m_image;
            static File file;
            //You have to define the name of the jar-file
            static String jarFile = "GifTest.jar";
            //Instance of the class GetImageIcon
            protected GetImageIcon gii = new GetImageIcon();
            public GifTest()
                    super("GifTest");
                    setSize(400,200);
                    //the name of the image and the name of the jar-file the image resides in
                    m_image = gii.getImageIcon("orb.gif", "GifTest.jar");
                    m_title = new JLabel(null, m_image, SwingConstants.CENTER);
                    getContentPane().add(m_title, BorderLayout.NORTH);
            public static void main(String argv[]) {
                    GifTest frame = new GifTest();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setVisible(true);
    public class GetImageIcon{
    * @param fileName the full qualified name of the file
    * from the root of your application. use a "/" before the
    * fileName, eg. /images/warning.gif
        public ImageIcon getImageIcon(String fileName, String jarName) {
            int counter, c, i = 0;
            byte buffer[];
            JarFile  jfile;
            JarEntry jentry;
            InputStream in;
            ImageIcon m_image;
            try{
                    // Create Jar-File object from JarFile
                    jfile = new JarFile(jarName);
            catch(Exception ex){
                    System.out.println("JarFile-Problem " + "\n" + ex);
                    return null;
            try{
                    // create Jar-Entry object from File-Name in JarFile
                    jentry = jfile.getJarEntry(fileName);
            catch(Exception ex){
                    System.out.println("JarEntry-Problem " + "\n" + ex);
                    return null;
            try{
                    // create InputStream from JarEntry
                    in = jfile.getInputStream(jentry);
            catch(Exception ex){
                    System.out.println("JarEntry-Problem " + "\n" + ex);
                    return null;
            try{
                    //get uncompressed size of entry data in Jar-File and create byte-array with this size
                    buffer = new byte[(int)jentry.getSize()];
                    //write int-value 'c' (casted to byte) with read() and while-loop in byte-Array
                    while((c = in.read()) != -1){
                            buffer[i] = (byte)c;
                            i++;
            catch(Exception ex){
                    System.out.println("in.read()-Problem " + "\n" + ex);
                    return null;
            try{
                    //create ImageIcon with byte-Array 'buffer'
                    m_image = new ImageIcon(buffer);
            catch(Exception ex){
                    System.out.println("ImageIcon-Problem " + "\n" + ex);
                    return null;
            // return the created ImageIcon
            return m_image;
    }

  • How to get resources from jar-files

    Hi
    in my app I load an image via the Toolkit.getImage() method.
    Works fine if the app and the image are in folders on disk.
    It fails to load the image, if the app (and the image) is packed in a jar file.
    How can I get the image from there?
    I try to get the image as follows:
    String s = getClass().getResource("MyApp.class").getFile();
    AppPath = s.substring(0,s.lastIndexOf("/"));
    String PathToImages = "/images";
    MyImage = (Image)Toolkit.getDefaultToolkit().getImage(AppPath+PathToImages+"/logo32.gif");The App starts and works, it just fails to load the images.
    Any solutions??
    thanx in advance
    Herby

    This is actually pretty easy. First a little background.
    A Jar file is just a Zip file, with a few constructs for Java.
    The getResource() method is used to create a mapping to data within the Jar file, but is actually not necessary after you know how the mapping works.
    Just to give you an example of getResource:
    // returned is a url to the resource you want from your Jar file.
    URL myURL = MyClass.class.getResource("images/myimgage.gif");
    // then you can use this URL to load the resource
    Image img = getImage(myURL);If you were you look at the value of myURL you would see something similar to the followiing.
    jar:http://www.mywebsite.com/mydir/myjarfile.jar!/images/myimage.gifJust to break it down for you.
    The line always starts with the word jar:
    Followed by the path to your jar file.
    A sepearator !/
    Then the file you are loading from the Jar file.
    jar:     path_to_jar_file     !/     path_to_resource_in_jar_fileSo if you'd like, you could just create a URL object, and define the path to the object using the above method rather than using getResource.
    Anyway, back to your code. What I would do is print out what you get for:AppPath+PathToImages+"/logo32.gif"I'm thinking you might be getting 2 "/" in your path because I think:AppPath = s.substring(0,s.lastIndexOf("/"));will leave the "/" at the end and the next line you add the "/" in front of the image directory name. So you my have the following for your image path.mypath//images

  • Gif files placed in a jar file. Help to get these files.

    I have placed all the gif files in a jar file.
    added the gif.jar to the project in the required libraries of project properties.
    In the toolbar class I gave this.
    JButton btnNew = new JButton(new ImageIcon("new.gif"));
    and was expecting it to shpw the icon but I didn't get it?
    Can I place the gifs in a jar file.
    What else can I change/check to see the icons?
    Thanks.

    Ok, lets try it this way:
    I have small samples on my server, which solve your
    problem. If you look at them, you can see
    how it works from a working example as starting point.
    CAUTION: This one ONLY works, if you have
    selected a JVM 1.3x.
    [ It doesnt work for jvm 1.4, because it references
    the main class in unnamed space. Thanks SUN ! -
    why was this needed ??? (security I guess) ]
    Steps:
    1) goto http://www.snowraver.org/java/index.htm
    2) download the "jarcreator.jar" example
    [ There is a small link "Download JarCreator.jar -
    although you also can start it as WebStart application
    if you click on the big button on that homepage ]
    3)
    The jar file contains the classes as well as the
    java source files and 2 gif pictures, which are
    loaded using the above explained method
    "LoadImageIcon"
    You can see how it works from that example.
    For extracting the source files, you can rename it
    and give it the ending .zip on windows, then
    you can extract all files using WinZip )
    The main class (called Idefix above) must be outside
    any package, that is, there must not be
    a package statement at the beginning.
    Some notes:
    If you are working without jar file, the method
    can return an ImageIcon object, although it
    couldnt find it. In this case, the width and length
    of that ImageIcon are zero.
    Usually no problem. But imagine you use the
    image icon for a tiled background. You loop
    would be endless then.
    It's a good idea to inspect the width of an imageicon
    for checking its greater zero.

  • SSIS Package resources

    Hello, can someone please guide me to some resources on creating SSIS packages that read data from files, load data into SQL server tables and interface with BPC using the SAP provided extensions to SSIS.
    Thanks.

    Hey Zack -
    This is pertaining to Version 5, but the same procedures translate to later versions...
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2027ebee-a928-2a10-4485-b88c926f5e24
    Good luck!
    Sean

Maybe you are looking for