Loading Xlet via .jar

Hi everybody,
i've got an Xlet containing about 100 classes and some resources. Since the startup-time is beyond the pale when files are loaded separetely by the object carousel, I want to load them with some .jar-files.
Therefore I wrote a custom ClassLoader that overrides the loadClass(String,boolean)-method as required in JDK1.1.8, reads the .jar as dsmccObject and defines/resolves the class. And everything's working so far.
part of sample code for loading from repository:
<code>
DSMCCObject dsmccZipFile = new DSMCCObject("test1.jar");
dsmccZipFile.asynchronousLoad(this);
FileInputStream fi = new FileInputStream(dsmccZipFile);
ZipInputStream zis = new ZipInputStream(fi);
ZipEntry entry = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while((entry = zis.getNextEntry()) != null){
     String entryName = entry.getName();
     if(entryName.equals(className+".class")){
          buffer = new byte[1024];
          int len=0;
          while((len=zis.read(buffer)) != -1){
               baos.write(buffer, 0, len);
          zis.closeEntry();
          zis.close();
          byte[]classBytes = baos.toByteArray();
          baos.close();
          return classBytes;
</code>
Cause I'm a newbie to classLoaders, I have the following problem:
The classes from the jar files are not known at build-time, so that I'm not able to do typecasting and calling the classes' methods.
The only way I handled the problem was the ReflectionAPI.
<code>
Class c = mcl.loadClass("test", true);
Object o = c.newInstance();
Method method = c.getMethod("aMethod", new Class[0]);
method.invoke(o, new Object[0]);
</code>
It works, but i don't like this solution, since it will result in complex code and the reflection's performance is not so high in comparison to direct method calls.
Another solution would probably be a common known interface, which calls methods, but that's worse i think and i had to implement the interface in all classes.
=> my questions:
1) Is there a common solution for jar-loading in MHP (i'm surely not the only one with a bad startup-time if loading files seperately)?
2) If not: is there a better solution than mine (using the reflection api) (the source will be the same: initial ClassLoader.class and .jar's send from same source over the oc)?
3) Should I extend org.dvb.lang.DVBClassLoader (I simply extended java.lang.ClassLoader) and which parentClassLoader should I use as second parameter? I tested it once with the Xlet's ClassLoader (getClass().getClassLoader()) but the problem is of course still the same.
4) Is there a reason that there is no jar support in the mhpAPI / environments (resp. those i know)? I simply used ZipInputStream instead of JarInputStream. Are jar classes available for download anywhere?
THX
regards,
Ben

Thanks to desperado for pointing out that you couldn't load classes from JAR files. I thought that was the case, but couldn't find where in the spec said it, so I assumed I was wrong. Ho hum.
To answer your questions:
- caching can be done on either the module level of the file level. MHP is pretty flexible about this, and doesn't define how much cache will be present (having no cache at all is acceptable, but most boxes have some)
- module arrangement will not always help, but it does make things easier. What you can do in DSM-CC that you can't do in HTTP is change the repetition rate of modules, so that commonly-used modules are transmitted more often (and thus have less latency) than less commonly used modules. Of course, this does affect the time needed to transmit the entire carousel.
- jars work pretty well in an internet app, but they're much less use in a DTV environment because you're transmitting your apps in a carousel. See below for why this is the case.
- you are right that you have to load files separately and not from JAR files. Loading from JAR files is not interoperable.
Loading classes from a JAR file would be slower because you have to wait for the entire file to load before you get any classes out of it. Depending on the size of your file, this can have a number of problems:
1) you need to load the entire JAR file. This means that you have to load all of the files, not just the ones you need, which takes longer. You're still only transmitting your object carousel at the same speed.
2) using modules that group together your files in a logical way may make better use of the DSM-CC cache in the receiver. If the receiver caches modules, then grouping files that are used together in the same module means that you will have less latency when loading files froma cached module. This gives you some of the benefits if using a JAR file in a more flexible way.
3) DSM-CC can compress the data in your files before transmitting it, so using a JAR file won't actually help you much in terms of reducing space.
The only tutorials that I know of that discuss DSM-CC are mine and the ETSI documentation. If you find any more, please let me know.
Steve.

Similar Messages

  • Loading an entire JAR via a classloader

    Hi how would I load an entire JAR file via a classloader. Currently I'm able to load one file at a time (in this case org.w3c.dom.Node) as shown below:
    import java.net.*;
    public class MyJarLoader {
       public static void main(String [] args) throws Exception {
         URL[] urlsToLoadFrom = new URL[]{new URL("file:subdir3/xml-apis.jar")};
         URLClassLoader loader1 = new URLClassLoader(urlsToLoadFrom);
         Class cls1 = Class.forName("org.w3c.dom.Node", true, loader1);
         System.out.println("Loaded '"+cls1.getName()+"'");
         org.w3c.dom.Node Node = (org.w3c.dom.Node) cls1.newInstance();
    Thanks

    Figured this one out as below. Note this is the simplistic solution since it requires that the jar files be present in the classpath. If not, you will have to write your own loadClass method to read the data from the zip (& then can't use the method 'Class.forName()').
    Regards
    //Load Apache JAR files
    URL[] urlArrToLoadFrom = new URL[]{new URL("file:xalan-j_2_5_0/xml-apis.jar"),
                new URL("file:xalan-j_2_5_0/xercesImpl.jar"), new URL("file:xalan-j_2_5_0/xalan.jar")};
    //Create a URLClassLoader to access jar files
    URLClassLoader urlLoaderGeneric = new URLClassLoader(urlArrToLoadFrom);
    //Foreach jar file, open, load class files & close
    for(int i=0; i<urlArrToLoadFrom.length; i++) {
    //Debug
       System.out.println(urlArrToLoadFrom.toString());
       //Open zip file
       ZipFile zf = new ZipFile(urlArrToLoadFrom[i].getFile());
       for (Enumeration enum = zf.entries(); enum.hasMoreElements();) {
         //Get entry
         ZipEntry ze = (ZipEntry) enum.nextElement();
         //Only load if it's not a directory and it's a class file
         int iIndexClass = -1;
         if (!ze.isDirectory() && ((iIndexClass = ze.getName().indexOf(".class")) != -1)) {
             //Remove .class & replace / with .
             String strApacheClassName = (ze.getName().substring(0,iIndexClass)).replace('/','.');
             //Load class file
             Class classApache = Class.forName(strApacheClassName, true, urlLoaderGeneric);
             System.out.println("Loaded '"+classApache.getName()+"'");
       //Close zip
       zf.close();

  • Batch loading with sdordf.jar.

    Hi Guys
    I have just tried a batch load with sdordf.jar.
    In my first attempt there was a mistake in the n3 file.
    After correcting the file and re running I now get the error.
    Connecting to jdbc:oracle:thin:...........
    Append mode
    Copy existing data out
    Just load triples into one column
    Temporary table already exists!
    java.sql.SQLException: ORA-00955: name is already used by an existing object
    ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 3326
    ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 3362
    ORA-06512: at "MDSYS.RDF_APIS", line 786
    ORA-06512: at line 1
    Can anyone tell me what the name of this temporary table is, so that I can get rid of it.
    Cheers
    Phil

    Hi Mellie
    After having a little break I have installed the jena patch during which I had to drop the network and model created before.
    I tried running a batch load as before but I still get the error message saying the temporary table already exists.
    I tried the clean up routine as suggested but get the error.
    SQL> exec sdo_rdf.cleanup_batch_load('researchdata')
    BEGIN sdo_rdf.cleanup_batch_load('researchdata'); END;
    ERROR at line 1:
    ORA-13199: Batch load cleanup failed. ORA-00942: table or view does not exist
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 17
    ORA-06512: at "MDSYS.SDO_RDF", line 1016
    ORA-06512: at "MDSYS.SDO_RDF", line 1022
    ORA-06512: at line 1
    I run it as mdsys as you said.
    Any other suggestions?
    Cheers
    Phil

  • Loading Facelets via ResourceHandler

    Hi there,
    can anyone tell me what's the main difference between JSF 2.0/2.1 and JSF 2.2 regarding to "Loading Facelets via ResourceHandler".
    I searched many articles and discussions and regarding to Flows and reosource library contracts there are some thinks that are not really clear to me and might be still in discussion
    In my opinion facelets and resources are loaded the same way now. The loading mechanism is unified now. But what does this mean.
    Are Resources within the Facelets or Views are loaded relative to their path now ?
    E.g. a view located in /x/y/z/view.xhtml will load its resources from /x/y/z/css/style.css when using <link type="text/css" href=css/style.css"/> and not from the resources folder ?!
    It would be very helpful for me if anyone could provide a simple example or a link where i can the right information, because it's one of the 6 big ticket features ed burns is mentioning in every article and presentation i saw, but the background is not completly clear for me :-/
    Thanks in advance!
    Kind regards,
    Jannis
    Edited by: 988043 on Feb 14, 2013 1:49 AM

    Tank you Eddy, but it seems it does not work.
    The error message received from DTW is:
    - <BOM>
    - <BOM>
    - <BO>
    - <AdmInfo>
      <Object>66</Object>
      <Version>2</Version>
      </AdmInfo>
    - <ProductTrees>
    - <row>
      <TreeCode>A00001</TreeCode>
      <Quantity>1</Quantity>
      <TreeType>iProductionTree</TreeType>
      </row>
      </ProductTrees>
    - <ProductTrees_Lines>
    - <row>
      <Currency>USD</Currency>
      <IssueMethod>im_Backflush</IssueMethod>
      <ItemCode>A00006</ItemCode>
      <Price>160</Price>
      <PriceList>1</PriceList>
      <Quantity>3</Quantity>
      <Warehouse>01</Warehouse>
      </row>
    - <row>
      <Currency>USD</Currency>
      <IssueMethod>im_Backflush</IssueMethod>
      <ItemCode>S10002</ItemCode>
      <Price>160</Price>
      <PriceList>1</PriceList>
      <Quantity>3</Quantity>
      <Warehouse>01</Warehouse>
      </row>
      </ProductTrees_Lines>
      </BO>
      </BOM>
      <ErrorMessage>A00001 - Errore definito dall'applicazione o dall'oggetto</ErrorMessage>
      </BOM>

  • How to load an applet jar file?

    Hello everyone,
    I have an applet that uses my own jar file and approximately 6 third party jar files. I set up jar indexing (jar -i) which will download the jar files when they are needed. All seems to work well, but now I want to manually load the jar files which I cannot get working.
    When the applet starts, about 1/2 of the jar files are downloaded (because they are needed at startup). I then want to load the additional jar files in the background, after the gui is initialized. I have tried this using the below thread which is executed from within the applet's start method:
    // Try to load additional jar files in background by loading a class from each jar file.
    Thread loadClass = new Thread() {
      public void run() {
        System.out.println("Loading classes...");
        try {
          // Tried loading classes this way, doesn't work.
          getClass().getClassLoader().loadClass("pkg1.Class1");
          getClass().getClassLoader().loadClass("pkg2.Class2");
          getClass().getClassLoader().loadClass("pkg3.Class4");
          getClass().getClassLoader().loadClass("pkg4.Class4");
          /* Loading classes this way doesn't work either.
          Class.forName("pkg1.Class1");
          Class.forName("pkg2.Class2");
          Class.forName("pkg3.Class3");
          Class.forName("pkg4.Class4");
        catch(ClassNotFoundException e) {
          // First attempt to load a class (pkg1.Class1) throws exception.
          System.out.println("Can't find class: " + e.getMessage());
    loadClass.start();As you can see from above I am trying to load a class from each of the jar files so that the jar files would load into memory/cache. Unfortunately, it cannot find the classes. These are the errors from the java console:
    Loading classes...
    Loading: pkg1.Class1
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with no proxy
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with cookie "JSESSIONID=some_big_long_char_list"
    Can't find class: pkg1.Class1
    So it appears the jar file is not being downloaded. When I take away the dynamic jar loading (removing the "jar -i" & adding them all to the applet archive list) the thread executes correctly. So I know the class names, etc, are correct. How does one load an applet jar file?
    Any help/suggestions are appreciated.

    The above error I posted was because I forgot to index the jar files. That is why it couldn't find the jar file. I thought I was getting farther along with my problem, but I apparently just forgot to index the jars. I am now getting the problem that I got yesterday...
    The applet freezes/hangs when it hits the thread. The GUI never opens (even though I'm running this thread right after the gui shows). The java console quits responding and the applet just stays the grey screen. I also tried the invoke later that you suggested.
    public void start() {
      // ...initialize gui...
      // Applet freezes and remains grey, also the java console freezes.
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          System.out.println("Loading classes...");
          try {
            // When I comment out the below forName calls, the thread will still run evidenced through the done print statement.
            Class.forName("pkg1.Class1");
         Class.forName("pkg2.Class2");
         Class.forName("pkg3.Class3");
         Class.forName("pkg4.Class4");
            System.out.println("...Done loading classes");
          catch(Exception e)     {
            System.out.println("Can't find class: " + e.getMessage());
    }

  • Loading library from jar file

    Hi all,
    My question is can we load library from jar file using System.load() method.
    ex:
    myJar.jar
    |
    |----com.test.common.Util
    which conatins a method to load library from jar file itself, before that i used to load from File
    |---libraries/MozillaParser/......
    Iam able load from Local system,
    File parserLibraryFile = new File("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    File mozillaDistBinDirectory = new File("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(parserLibraryFile.getAbsolutePath() , mozillaDistBinDirectory.getAbsolutePath());
    but i am unable to load from jar file
    URL url = ClassLoader.getSystemClassLoader().getResource("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    URL url1 = ClassLoader.getSystemClassLoader().getResource("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(url.toString(), url1.toString());
    Thanks in advance.

    That's a really confusing post.
    The easiest way to make sure you can use the classes in a jar file is to copy the jar file to the "/jre/lib/ext" subfolder of your JDK. These classes will be visible to all applications.

  • Hi everyone i tried to modify BCA so i can use a usb to load windows via BCA but now it doesn't load when i double click it!?

    i tried to modify BCA so i can use a usb to load windows via BCA but now it doesn't load when i double click it!? any ideas?

    iv solved it now

  • 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 dimension via plsql

    Hi
    I am trying to create a dimension and load it via plsql and am able to create dimension and its corresponding table in database.I am quite unsure of how to load the dimension D_OFF from an equivalent relational table R_OFF
    I have a dimension D_OFF with following structure.
    Hierarchy:OFFKEY is child of OFF30 is child of OFF20 is child of OFF10
    Levels -->Attributes
    OFF10 ID--> CD ,DSCR
    OFF20 ID -->CD ,DSCR
    OFF30 ID-->CD ,DSCR
    OFFKEY ID-->CD,DSCR,UPDATE BY,UPDATE_DATE,CREATE BY, CREATE_DATE
    I have created the dimension and the table structure in the database and are as follows
    CREATE DIMENSION D_OFF
    LEVEL "OFF10" IS "OFF10_ID"
    LEVEL "OFF20" IS "OFF20_ID"
    LEVEL "OFF30" IS "OFF30_ID"
    LEVEL "OFFKEY" IS "OFFKEY_ID"
    HIERARCHY "STANDARD" (
    "OFFKEY" CHILD OF
    "OFF30" CHILD OF
    "OFF20" CHILD OF
    "OFF10"
    ATTRIBUTE "OFF10" DETERMINES ( "OFF10_CD", "OFF10_DSCR" )
    ATTRIBUTE "OFF20" DETERMINES ( "OFF20_DSCR", "OFF20_CD" )
    ATTRIBUTE "OFF30" DETERMINES ( "OFF30_DSCR", "OFF30_CD" )
    ATTRIBUTE "OFFKEY" DETERMINES ( "OFFKEY_DSCR", "UPDATE_DATE", "OFFKEY_CD", "UPDATE_BY", "CREATE_DATE", "CREATE_BY" )
    CREATE TABLE "D_OFF"
    ( "DIMENSION_KEY" NUMBER NOT NULL ENABLE,
    "OFF10_ID" NUMBER,
    "OFF10_DSCR" VARCHAR2(200),
    "OFF10_CD" VARCHAR2(500),
    "OFF20_ID" NUMBER,
    "OFF20_CD" VARCHAR2(500),
    "OFF20_DSCR" VARCHAR2(200),
    "OFF30_CD" VARCHAR2(500),
    "OFF30_DSCR" VARCHAR2(200),
    "OFF30_ID" NUMBER,
    "UPDATE_DATE" DATE,
    "CREATE_DATE" DATE,
    "UPDATE_BY" VARCHAR2(250),
    "OFFKEY_ID" NUMBER,
    "CREATE_BY" VARCHAR2(250),
    "OFFKEY_CD" VARCHAR2(500),
    "OFFKEY_DSCR" VARCHAR2(200),
    CONSTRAINT "OFFE_DIMENSION_KEY_PK" PRIMARY KEY ("DIMENSION_KEY")
    My source table is
    CREATE TABLE "R_OFF"
    ( "DIMENSION_KEY" NUMBER NOT NULL ENABLE,
    "OFF10_DSCR" VARCHAR2(200),
    "OFF10_CD" VARCHAR2(500),
    "OFF20_CD" VARCHAR2(500),
    "OFF20_DSCR" VARCHAR2(200),
    "OFF30_CD" VARCHAR2(500),
    "OFF30_DSCR" VARCHAR2(200),
    "UPDATE_DATE" DATE,
    "CREATE_DATE" DATE,
    "UPDATE_BY" VARCHAR2(250),
    "OFFKEY_ID" NUMBER,
    "CREATE_BY" VARCHAR2(250),
    "OFFKEY_CD" VARCHAR2(500),
    "OFFKEY_DSCR" VARCHAR2(200),
    Could you please let me know how to load the dimension via plsql.
    Best Regards,
    Sri

    I assume you're quite sure that the relevant dimension does at least sometimes get updated by the build process, and that you've searched the outline just in case the member was added somewhere you didn't expect.
    How is the data pulled in to the load rule? If it's from a relational database, check the SQL query used to extract it (could there be a WHERE clause restricting records)? If it's from a flat file, check the select / reject criteria set up in the load rule.
    Another possibility is that your load rule is set up to skip X lines at the beginning, and the new member appears there.
    You could build a brand new load rule against a test copy of the cube and confirm that ABC does build in successfully (that at least tells you that the problem is in your rule somewhere).

  • Trying to access the java script files via jar file in WEB SERVER

    hi all,
    I am trying to access the java script files via jar file ,which is present in Apache webserver in order to minimise the number of hits to app server.some thing like cache ...
    in jsp the code goes like this...
         <script type="text/javascript"  archive="http://localhost:14000/dojo.jar!" src="dojo.jar/parser.js" " ></script>{code}
    But i am not able to access the js file which is put in jar file present in the  webserver.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    You can use DWR (Direct Web remoting) for that. It is easy AJAX for java. ou can directly call the java script function from java class and also java class from javaScripts..
    Regards,
    Hardik

  • 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

  • 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.

  • 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

  • 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.

  • Load balancing via CHOC12/STS3

    Hi, our customer has a connection between 2 x 12012 via the 4 embedded channels of CHOC12/STS3 module.As every subinterface has its own ip-subnet we have 4 equal paths to every destinations.
    Customer wants to configure dCEF per-packet load balancing and is concerned if he can get packet sequence problems for his VoIP applications like it may happen on 'normal' equal path cost connections when load balancing per-packet instead of per-destination.
    Does anybody know if this can be a concern on the embedded channels ?
    Regards Guenther

    Generally speaking, for a given source-destination pair, with Per-packet load balancing enabled, packets might take different paths which could introduce reordering of packets. Thus Per-packet load balancing is inappropriate for voice over IP traffic and also for certain other types of data traffic that require packets received to be in sequence. For more information please see
    http://www.cisco.com/en/US/products/sw/iosswrel/ps1828/products_configuration_guide_chapter09186a00800ca62c.html#3589. Whether the CHOC12/STS3 module has some special meachanism built in to take care of this is unknown to me. Per-packet load balancing via CEF is not supported on Engine 2 Gigabit Switch Router (GSR) line cards (LCs).

Maybe you are looking for