Problem in bundling gifs in jar file.

Hello all,
I am having following package structure.
/* For example */
com.course.explorer;
com.course.explorer.toolbar;
and an image directory having all images in
com/course/explorer/images
Now to associate an ImageIcon with a button in toolbar package.
/* for example */
code from NewCourseBut.java present in com.course.explorer.toolbar package.
ImageIcon img = new ImageIcon(
getClass().getResource("../images/new_course.gif"));
Now my problem is when I am trying to run a jar file (containing all my code+images) it throws NullPointerException.( Unable to find the image new_course.gif)
I am not able to understand wher I am going wrong.
Can anyone please help me out in finding my fault.
Smiles,

Hello All,
Is there any standard way of incorporating gifs in an Jar file.
Consider that one is extracting an ImageIcon for a Toolbar button and for the same the gifs is present in an "images" directory.
I did tried alot of permutation & combinations still no luck.
How one need to proceed for same ?
Any guidance is welcome.
Smiles,

Similar Messages

  • How do I read the images I bundled into the jar file?

    I just wrote an applet that uses
         Toolkit tk = Toolkit.getDefaultToolkit();
         tk.getImage("blah.gif");to load a bunch of image files. The class file and gif images were bundled into a jar file to minimize the number of connections the browser has to make to the server.
    The applet works fine in appletviewer but trips a java.security.AccessControlException: access denied (java.io.FilePermission select.gif read) when run in a browser. I know you normally use Applet.getImage(URL) to load images but wont that circumvent the JAR file and make a seperate connection to the server for each image? That would defeat the purpose of using a JAR file.
    How do I access the image files I bundled into the JAR file?

    From your Applet class, write the following:
    URL imgUrl = getClass().getResource("blah.gif");
    Image img = getImage(imgUrl);The returned URL will be from the Applet class ClassLoader, which will look into the specified archive (jar) file.

  • Problem trying to cataloge a jar file OBPM 10.3.1.0

    Hi,
    I´m having problems when i cataloge a jar file, in OBPM suite 10.3.1.0, it is an itext jar file. I´ve been trying to cataloge older and newer versions of the Itext jar file but there´s no difference in the outcome.
    I create the external resource, but when i try to cataloge the package it doesn´t work
    The message it returns is:
    [Error] Excepción de introspección: Internal Error: java.lang.VerifyError: (class: com/lowagie/text/RectangleReadOnly, method: <init> signature: (Lcom/lowagie/text/Rectangle;)V) Bad access to protected data..
    is there anything i can do to solve this problem?..
    Thanks for your time
    Alfredo Butrón
    Alkimia Consultores

    Hi Dan,
    I´ve done what you told me, i buid a helper class to invoke the iText classes ,and i just cataloge the helper class keeping all the jar files only in the external resource
    When i run my class out of OBPM it works fine, but when i try to invoke my class from OBPM with the same jar classes i use in a external way i get the following message:
         at fuego.component.ExecutionThread.work(ExecutionThread.java:839)
         at fuego.component.ExecutionThread.run(ExecutionThread.java:408)
    Caused by: java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending(Z)V
         at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:482)
         at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:381)
    i change the version of iText.jar many times and i get the same message..
    thanks in advance
    ALfredo

  • Problems ressources bundles in a jar

    Hi !
    I have a ".propeties" file wich I acces from a java application.
    Launched from Eclipse : no prb !
    Launched form a exectutable jar : MissingRessourcesException.
    But the ressource is in the jar !
    Here is the code :
    import java.util.Locale;
    import java.util.ResourceBundle;
    public class LabelsRB {
    private static Locale loc = Locale.ENGLISH;
    public static ResourceBundle rb = null;
    public static String name = null;
    static {
    name = "Labels_";
    rb =
    ResourceBundle.getBundle(
    "editor.ressources.Labels_" + loc.getLanguage());
    public static String getString(String key) {
    try {
    return rb.getString(key);
    } catch (Exception e) {
    System.err.println(
    "Erreur Bundle " + name + " " + key + " non trouve");
    return new String("####");
    Thanks !
    Message was edited by:
    dideux

    Is there a problem with the way you created the jar file? Can you list your manifest file?

  • Deployment problems when using several ejb-jar files

    Hello All,
    I am having problems with deployment of my J2EE application. My EAR file has several EJB-JARs, one for each entity bean. However I refer to the other EJBs in one EJB. Hence I included the <ejb-ref> element in the deployment descriptor of the entity bean. But I am getting the deployment error that "the bundle does not contain the bean name". I tried to change the <ejb-name> value (within the <ejb-ref> element) to the JNDI name of the EJB I am referring to, and also added the <ejb-link> tag specifying the location of the JAR file that has the EJB. None of the attempts worked.
    Can someone help me out on how I am supposed to go about when I have several ejb-jar files as opposed to a single one? I am deploying my app on Sun ONE AS 7.0.
    Thank you,
    PS: I am posting this message on several forum topics. Please disregard this message if you have seen/answered this message. Thanks.

    Hi ,
    It would help if you could post the relevant snippets of your
    ejb-jar.xml. In general, you definitely shouldn't use jndi-name
    for any of the linking information. jndi-name is not part of the
    standard deployment descriptor. The syntax for the ejb-link is
    [ejb-jar uri]#ejb-name
    K

  • Problem with HelpSet in a jar file

    In our application, the content of the html-pages of the help
    set is not displayed ( the index is ! ) if we put the help set
    in a jar file.
    Withour using a jar file, it works fine.
    The problem appeared with all JavaHelp versions I tried (up to 2.0 beta)
    and using JREs >= 1.3.1_0x. Its funny that it works fine with 1.3.1
    Capitels in the file names are NOT the problem.
    Can anybody help me ?
    Do I have to include somethingh in the MANIFEST.MF file of
    the jar ? If so, what ?

    Check the case of the file names such as map.jhm File names are not case sensitive when in a jar file.

  • GIf and Jar files

    I want to put all image files used one of my programs in jar file(let's say "images.jar") so how can can I get the images file if the class who needs them is not in "images.jar'
    can I do like that ?
    JButton b=new JButton("OK");
    b.setIcon(new ImageIcon("image.jar/ok..gif"));

    Make sure the jar-file is in the classpath.... then ude getResource() or getResourceAsStream() to get hold of them.
    /Michael

  • Java Plugin and GIFs from Jar file...

    This used to work and I haven't looked at it for a while. First thing I did is run the old java applet web page with the old jar file, kinda just to lay eyes on the thing again.
    It had to download a new plug-in from Sun, and upon doing so, reports a new error indicating that the value for the cache_version attribute in the HTML is incorrect. It was 1.0 (always has been) and the plugin says it needs to be in X.X.X.X format instead.
    So, that isn't a nice change to make in the plugin at this time. However, if I just click okay and close the error dialog, at least it works fine after that.
    In my attempt to get rid of the dialog I change the cache version to 1.0.0.0, upon doing this
    the toolbar images no longer load, it says there is a java.io.FilePermission error.
    We'll it doesn't make any sense that a mere change to cache version caused that so I changed the version back to the apparently erroneous value of 1.0, and then the toolbar images work again ! But I get the permission error.
    Any ideas how I can fix these pesky images loading from a jar ?
    Do you have any code that loads images out of a jar in an applet succesfully ?
    Or have any suggestions on what I could try ?
    Below is the code I'm using to load the images, where icoXXXX is a ImageIcon object, and fileameXXXX is a string containing a relative file path such as "images/highcolor/toc_color.gif" (this code executes in the applet's init() method (called by the plugin):
    java.net.URL urlToc = getClass().getResource(filenameToc);
    java.net.URL urlTocBW= getClass().getResource(filenameTocBW);

    dunno why but
    getClass().$blah... wouldn't work for getting images in an applet from a jar for me.
    But this does:
    Class c = Class.forName("java.lang.Object");
    InputStream in = c.getResourceAsStream("/images/myImage.gif");
    byte[] buffer = new byte[in.available()];
    in.read(buffer);
    icon = new ImageIcon(buffer);
    when included with the usual default exception handling.
    Lemme know if that doesn't work for you.
    cheers
    -Ragu
    Overweight is when you step on your dog's tail and it dies.

  • Problem while importing the ejbean jar file as model

    hi
    i created one sample ejb appication and jar the same and then trying to import the same as model(using option like Import JavaBean Model) in my webdynpro,but is giving error there are no java beans to import.
    is it possible to import ejbbean like normal javabean?
    if yes,why the above problem is coming?
    can anyone give the solution?
    thanks in advance
    Vasu

    Satish,
    thank you for reply.
    this way i already implemented and it was worked fine.
    we can not suggest to publish our own ejb component as webservice right?
    and i am thinking one more way of doing that is, we can implement one value bean(normal java bean to communicate ejb component internally)and import that jar as our model class in webdynpro.
    is this scenario will work?
    if this works,then how to make jar file which is maintain the both javabean and ejbcomponent as one thorugh NWStudio.
    Thanks
    Vasu

  • Gifs in jar files

    I have an application that uses some gif files which are displayed using the ImageIcon object. How do i get it so that it can find the gifs within the jar file that the application is packaged in?
    Greg

    hi,
    a jar-file is to use like a directory and with the command 'getClass().getResource()' you get the real directory to your pictures (or other ressources).
    ex.
    your jar-file contains the following:
    /yourLib/YourClass.class
    /yourLib/img/pic1.gif
    then you can get the pic from your class 'YourClass.class' with the command
    ....setIcon(new javax.swing.ImageIcon(getClass().getResource("/yourLib/img/pic1.gif")));
    cu
    oliver scorp

  • Problem with creation of a jar file from inside a java program

    Hi,
    I am trying to create a jar file at runtime from within a java program.
    I am able to create a jar file just fine using:
    String[] jarArgs = new String[3];
    jarArgs[0] = "cvf";
    jarArgs[1] = "C:\temp\myjar.jar";
    jarArgs[2] = "C:\temp\this";
    sun.tools.jar.Main main1 = new sun.tools.jar.Main(System.out, System.err, "jar");
    main1.run(jarArgs);However, when I look at the jar it puts the absolute path to the files inside such as:
    C:\temp\this\is\my\package\Class.class
    instead of only this\is\my\package\Class.class
    When running the jar command from the command line it works just fine and I have the relative paths in my jar file.
    Does anyone have any experience with this and could help me out?
    Thanks in advance
    Edited by: mruf on Apr 11, 2008 1:51 AM

    Shouldn't jarArgs[2] = "-C C:\temp\this"

  • Problem While Loading mp3 From Jar File?

    Hello There
    I've Made a jar File That Contains mp3 file That Should be Played When the jar is opened
    but the file doesn't play?
    and my code snippet to load from the jar
    URL url=getClass().getResource("/file.mp3");
    MediaLocator ml=new MediaLocator(url);
    final Player player = Manager.createRealizedPlayer(url);
    I don't Know where's The Error
    Could any one Help?

    First_knight wrote:
    Hello
    -Yes I Use NetBeans 6.1 To create The Jar With The Following Steps:
    First I've Add The Sound File To a Package In NetBeans 6.1
    And Then Called The Sound From The Package And The Program Runs Okay Then I Made The jar
    and after making the jar now i have to call the sound file from the jar by the code mentioned above
    i used it and run the program it run okay but when i try to open the jar i hear no sound????????????
    I Don't know whyyyyyyyyy This seems to indicate that your app is finding the mp3 file. You would probably get a null pointer exception if the file wasn't found. Something else seems to be going on.
    -How are you launching the jar outside of NetBeans?...By Double Click On It
    I suggest trying to launch the jar using the command promptjava   -cp   YourJarFile.jar  YourMainClassAnd if that works, try java   -jar   YourJarFile.jarAnd if that works, your computer's file association is not set up correctly.

  • Problem for downloading Weather client.jar file

    Hi,
    I downloaded Weblogic server6.1 windows version.my system enveronmet is:Compaq system
    with 20GB and 128MB Ram
    OS is windows-98.Iam able to run server and compile and create example Weather.ear
    file.but iam geting problem when iam try to download Client.jar from this URL:http://host:port/weather
    here i change host is my system name and port is 7001 like what ever you given instruction
    in document.but it's not opning that file it's giving error that error message I
    attach with this message.this is my problem please tell me how to solve this problem.
    Thanking you
    seenu
    [att1.html]

    I would like to know too. I am a newbie on this matter as well. I am curious about the RUNCLIENT. Can I use java <className that references the EJB>?

  • Problem regarding Deployment of EJB jar file

    I am getting the following problem when i am trying to deploy my EJB on to the Weblogic 8.1 using the EjbModules option.
    Please help me
    Exception:weblogic.management.ApplicationException: prepare failed for mybank Module: mybank Error: Exception preparing module: EJBModule(mybank,status=NEW) Unable to deploy EJB: E:\OnlineBanking\mybank\mybank.jar from mybank.jar: weblogic.ejb20.deployer.DeploymentDescriptorException: Unable to load a class specified in your ejb-jar.xml: Class bytes found but defineClass()failed for: 'mybankEJB' at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.initializeBeanInfos(Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Lweblogic.utils.classloaders.GenericClassLoader;)V(MBeanDeploymentInfoImpl.java:550) at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.<init>(Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Lweblogic.utils.classloaders.GenericClassLoader;Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.utils.jars.VirtualJarFile;)V(MBeanDeploymentInfoImpl.java:232) at weblogic.ejb20.deployer.EJBDeployer.prepare(Lweblogic.utils.jars.VirtualJarFile;Ljava.lang.ClassLoader;Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Ljavax.naming.Context;Ljava.util.Map;)V(EJBDeployer.java:1302) at weblogic.ejb20.deployer.EJBModule.prepare(Ljava.lang.ClassLoader;)V(EJBModule.java:498) at weblogic.j2ee.J2EEApplicationContainer.prepareModule(Lweblogic.utils.classloaders.GenericClassLoader;Lweblogic.j2ee.J2EEApplicationContainer$Component;Z)V(J2EEApplicationContainer.java:3101) at weblogic.j2ee.J2EEApplicationContainer.prepareModules([Lweblogic.j2ee.J2EEApplicationContainer$Component;Ljava.lang.String;Z)V(J2EEApplicationContainer.java:1560) at weblogic.j2ee.J2EEApplicationContainer.prepare([Lweblogic.j2ee.J2EEApplicationContainer$Component;[Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)V(J2EEApplicationContainer.java:1208) at weblogic.j2ee.J2EEApplicationContainer.prepare(Ljava.lang.String;[Lweblogic.management.configuration.ComponentMBean;[Ljava.lang.String;)V(J2EEApplicationContainer.java:1051) at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareContainer()V(SlaveDeployer.java:2444) at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer()Z(SlaveDeployer.java:2394) at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare()V(SlaveDeployer.java:2310) at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(Lweblogic.management.deploy.OamVersion;Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;Z)V(SlaveDeployer.java:866) at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(Lweblogic.management.deploy.OamDelta;Lweblogic.management.deploy.OamVersion;ZLjava.lang.StringBuffer;)Z(SlaveDeployer.java:594) at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(Ljava.util.ArrayList;Z)V(SlaveDeployer.java:508) at weblogic.drs.internal.SlaveCallbackHandler$1.execute(Lweblogic.kernel.ExecuteThread;)V(SlaveCallbackHandler.java:25) at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178) at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    In addition to the JavaEE Tutorial link above, Sun Java System Application Server 9.0 Documentation is here:
    http://docs.sun.com/app/docs/coll/1343.3
    -cheng

  • Jar file and classpath problem

    I0m writing a program that use the kunststoff.jar Look&Feel.
    Now I would like to put all I'm writing into a jar file but I always have a NoClassFoundException when I try to start my application.
    here is a MANIFEST:ME I'm using:
    Manifest-Version: 1.0
    Created-By: 1.4.2-beta (Sun Microsystems Inc.)
    Main-Class: JListaR.JListaR
    Class-Path: kunststoff.jar img\ .why this don't work?

    Unfortunately you can't embed jars within a jar and
    expect them to be referencable for the classpath from
    outside the main jar. The "Class-Path" attribute in
    the manifest is used to refer to other jar files
    outside of your jar file.
    The usual approach to solve this problem is to unpack
    the jar files you want to embed and then rejar
    everything together in one big jar file again. This
    isn't always a great approach though, I know I'm
    looking for an alternative. So far my only alternative
    is dynamic class loading using a classloader, however
    this isn't great if you need to refer to several
    hundreds or even thousands of classes.thank you very mach...now I understand because it dosen't work correctly!

Maybe you are looking for