Relative URLs not working in JAR file once JAR is moved

I've been loading images with the following:
public static final ImageIcon anIcon = new ImageIcon("iconName.gif");
This works fine when all the class files are in the same folder with the gifs. I then packaged the whole folder into a .jar file, moved the resulting .jar file to another directory, tried running it and none of the icons loaded. They are present in the .jar file, why doens't the relative URL still work? Is there simply another way to write the URL so that it knows to look in the .jar file?
Thanks for help,
Robert Douglass

Is there simply another way to write the URL so that it knows to look in the .jar file?Once you put the class files along with your gif files in a jar, you have to access the gif file like this:
import java.net.*;
URL url=myClass.class.getResource("iconName.gif");
ImageIcon anIcon = new ImageIcon(url);
Where myClass is the name of your class file.
V.V.

Similar Messages

  • Why does the new operating system not delete the moved files from their original location - it seems like an enormous waste of space, time and effort to clean up every file once you've moved it

    Why does the new operating system not delete the moved files from their original locations - it seems like an enormous waste of space, time and effort to clean up every file once you've moved it - also, when transferring large amounts of files it becomes a very large problem remembering which files were transferred and which not.

    You're going to need to be more specific, as I'm not quite sure I understand what you're talking about.
    If you're referring to copying from an external hard drive or flash drive, and you want to actually move files rather than copy them, you can hold down the option key to force it to do a "move" rather than a "copy." This is not new behavior, though... the Mac OS has worked this way as long as I can recall (and I've been using it since 1984).
    If you're having a problem with trying to move files from one place to another on a single drive causing them to be copied instead, that is likely because of some permissions issue preventing you from actually being able to move them.

  • Has anyone not working with .dv files had synchronization problems?

    Has anyone not working with .dv files had sound synchronization problems? I'm not exactly sure what the alternatives to DV are, but I think one of them is HD.
    The reason for asking this question is to help isolate the nature and cause of a very serious flaw in iMovie '11. In the original release of iMovie '11 (version 9.0) there was a small--but serious--synchronization problem. In the 9.01 there is a large synchronization problem. We know of one person who has not experienced the problem, and he is not working with DV files (media). So we want to find out if anyone who is using something other than .dv files is experiencing a lack of synchronization between sound and picture. Knowing the answer to this will help with figuring out where the cause lies. For the initial iMovie '11 release (9.0), you probably would not notice a problem unless you had very long event-clips, e.g., two hours long. Events get this long if you are transferring from analog 8 mm tapes. Even then, it would have to be in scenes in which the connection between event and sound is obvious, e.g., close ups of people talking. It isn't until the 9.01 release that most people would notice anything. All we need to do is establish one case of a synchronization problem in which the person is using something other than DV.
    Message was edited by: Paul Bullen

    Hopefully, the 9.0.2 release will make my question moot. Zyfert must have posted the announcement of the release just as I was formulating my question. Still, if you have information on the subject, it would be interesting to hear.

  • Itunes not working, get "missing file, reinstall itunes" message.

    1.  Itunes not working, get "missing file, reinstall itunes", message.
    2.  When try to reinstall itunes, gets as far as "starting services", then stops with message, "Apple mobile device failed to start. Verify that you have sufficient privileges to start system services."
    I am logged in to my laptop as Administrator.
    3.  After selecting "retry" and "ignore" a few times, install went ahead and got "Congrats, you have successfully installed itunes"
    When I went to itunes I got, " Itunes not installed correctly, please reinstall. Error7 (Windows error 126)".
    4. On reinstalling itunes yet again, got, "Programme cannot start because MSVCR80.dll is missing. Try to reinstall programme"
    Help !!!

    See if this post from turingtest2 helps : https://discussions.apple.com/message/24620553#24620553
    There is also this user-tip for troubleshooting issues with iTunes for Windows from turingtest2 : https://discussions.apple.com/docs/DOC-6562

  • Flash play installation not work - The exe file deelete automaticly and the process is still running

    Flash play installation not work - The exe file deelete automaticly and the process is still running

    Why i get no answer?

  • ExternalInterface not working when swf file is embed inside a dynamically cloned DIV element.

    ExternalInterface not working when swf file is embed inside a dynamically cloned DIV element.
    It seems that flash movie is identifed as 'undefined' inside document.
    //a statically placed div
    var staticdiv=document.getElementById('PropDiv');
    //dynamically placed div with object tag
    var dynDiv =staticdiv.cloneNode( true );
    var xD=50;
    var yD=50;
    if(dynDiv)
    dynDiv.style.display  = "block";
    dynDiv.innerHTML="<object classid=" + "\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"" + "codebase=" +
    "\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"" + "width=" + xD + "height=" + yD +
    "id=" + "\"external\"" + "align=" + "\"middle\"" + ">" +
                    "<param name=" + "\"allowScriptAccess\"" + "value=" + "\"sameDomain\"" + "/>" +
                    "<param name=" + "\"movie\"" + "value=" + "\"external.swf\"" + "/>" +
                    "<param name=" + "\"quality\"" + "value=" + "\"high\"" + "/>" +
                    "<param name=" + "\"wmode\"" + "value=" + "\"transparent\"" + "/>" +
                    "<param name=" + "\"bgcolor\"" + "value=" + "\"#ffffff\"" + "/>" +
                    "<embed src=" + "\"external.swf\"" + "quality=" + "\"high\"" + "wmode=" + "\"transparent\"" +"bgcolor=" + "\"#ffffff\""
    + "width=" + xD + "height=" + yD + "name=" + "\"external\"" + "align=" + "\"middle\"" + "allowScriptAccess=" + "\"sameDomain\"" +
    "type=" + "\"application/x-shockwave-flash\"" + "pluginspage=" + "\"http://www.macromedia.com/go/getflashplayer\"" + "/>" +
                    "</object>";
       dynDiv.style.top=50;
       dynDiv.style.left=100;
    document.body.appendChild(dynDiv);
    In above situation communication is not establised when a  funtion which is retruning boolean is called from flash using
    ExternalInterfcae.call.The return value of this function is getting as false inside flash.But the value is true in javascript.
    if (navigator.appName.indexOf("Microsoft") != -1) {
       return window[movieName];
      } else {
       return document[movieName];
    window["external"] is returning as 'undefined'.
    Please give a  solution to solve this.

    Note that you have different file names for the object (images/banner.swf) and the embed (images/banner1.swf)
    You also placed the embed in the middle of a param tag and nested all param tags.
    Because you didn't include a MIME type and the object doesn't have a classid for an ActiveX control for IE, I'm not sure what Firefox will be using.<br />
    The object doesn't have a data attribute to specify the file.<br />
    A separate embed is only needed when you specify a classid in the object.
    <pre><nowiki><div class="bannercontainer">
    <object width="940" height="445" type="application/x-shockwave-flash" data="images/banner.swf" >
    <param name="wmode" value="transparent" />
    <param name="movie" value="images/banner.swf" />
    </object>
    </div></nowiki></pre>

  • Quicklook does not work with WMV files and quick look no longer maintains resized views when viewing from a folder using the up/down arrows

    Quicklook does not work with WMV files and quick look no longer maintains resized views when viewing from a folder using the up/down arrows. Any fixes?

    Same problem here...

  • Im tryting to install new itunes but says windows installer, you are tring to use is a network resource that is unavailable. find folder itunes.msi  i dont have a folder like that and anything i use that is related does not work. help me?

    "you are tring to use is a network resource that is unavailable. find folder itunes.msi" i dont have a folder like that and anything i use that is related does not work. ive tryed to uninstall but still does the same thing when.

    Should the advice above not fix things for you...
    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • The Java JAR file "minecraft.jar" could not be launched.

    I just downloaded a new version of this game called Minecraft and it says: The Java JAR file "minecraft.jara" could not be launched. Check the console for possible error messages. I have checked the Console and it says: 
    15/10/2011 23:11:08 [0x0-0x1d01d].com.apple.JarLauncher[191] Failed to load Main-Class manifest attribute from
    15/10/2011 23:11:08 [0x0-0x1d01d].com.apple.JarLauncher[191] /Users/sabi1110/Desktop/minecraft.jar/minecraft.jar
    Help?

    How to Diagnose Jar File Problems
    Open Applications > Utilities > Terminal.app, and then type in the following:
    java -version
    java -jar <drag the minecraft.jar file here>
    Then press Enter. Copy and paste whatever error message appears.

  • "Display the number of found items in the find toolbar" Not work in xml file

    Word count feature that comes with version 32 does not work in xml file.

    This only happens when Firefox uses the "pretty print" layout if there is not XSL stylesheet file.
    * <b>about:config</b> page: layout.xml.prettyprint = false
    *http://mxr.mozilla.org/mozilla-release/source/content/xml/document/src/nsXMLPrettyPrinter.cpp
    *http://mxr.mozilla.org/mozilla-central/source/dom/xml/nsXMLPrettyPrinter.cpp
    *chrome://global/content/xml/XMLPrettyPrint.xml
    *chrome://global/content/xml/XMLPrettyPrint.xsl

  • Have been trying all weekend to upload Jpegs- either Send does not work or shows files uploading then shows error- never had this problem with Send Now-16 images total size 92MB-largest image 13MB

    Have been trying all weekend to upload Jpegs- either Send does not work or shows files uploading then shows error- never had this problem with Send Now-16 images total size 92MB-largest image 13MB

    Hi Ciaran19,
    Are you sending files from the Adobe Send interface, Adobe Reader, or the Outlook plug-in?
    Have you checked to see whether the files that you're sending appear in the Recent Files/Sent Files list when you're logged on to https://cloud.acrobat.com? (It could be that they're uploading, but not being sent.)
    It would also be worthwhile to send the files in smaller batches, to see whether a particular file or files is problematic, and causing the error.
    Please let us know how it goes. If you're still having trouble, please let us know where you're sending from, and whether you're able to send the files in smaller batches. It would also be helpful to know the exact error message that you're receiving.
    Best,
    Sara

  • Absolute URLs  not working when file is on a remote server.

    My client has asked me to provide a template for an investor relations section of their website. The HTML page or template for this page will be at the service providers site, but all the images etc. for the page will be linked to files on my clients server. Everything looks fine, but the absolute URL's in the .swf file back to my clients site aren't working.
    This is what the service provider's guidlines say, but I'm not sure where the code is supposed to go:
    Similarly, newer versions of the Flash Media Player installed by most users have a high level of security enabled by default. This is done to prevent Flash movies from playing on web pages that are hosted on different domains than the movie itself (again, to combat “phishing” or “spoofing”).
    You do have the ability to overwrite this feature by proactively developing your Flash file so that it contains the following lines of code:
    System.security.allowDomain(“*”)
    stem.security.allowInsecureDomain(“*”)
    Sy
    You should also add the following line of HTML within the embedded Flash call in your HTML template:
    <param name=”AllowScriptAccess” value=”always” />
    This solution requires edits to the ActionScript of the pre-compiled Flash file, and is not something we can edit. For further guidance and more information, please speak with the developer of your Flash file.
    Thanks

    the easiest way to deal with security issues is to avoid them.  if all files are on the same server, use relative urls.
    otherwise, you may have to deal with security issues.  whether you do or not, and if you do, how you deal with them, depends on what you're trying to do.
    you may be able to use System properties but you may need cross-domain security files.

  • Application URL not working properly

    We have a custom application hosted on weblogic8.1 cluster. And this is in production environment.
    What we observed was, I am using FireFox browser and works fine for me. And I noticed it did not work a few days ago only once. However, most of the other users use IE6.0 and seems not able to access this URL. So some tried using IE 7.0 and worked fine for some time. But, the problem persisted very often as few can and others cannot.
    Can anybody tell me what could be the problem or should I be modifying any files in weblogic server.
    This is working pretty fine in testing environement.

    Thank you very much for the hint, though I have not tried your suggestion. I tried a little more and found the following way might be simpler - using "java.url.*" and "java.io.*". Just a simple test:
    ============================
    URL url=new URL("ftp://usrname:password@hostname/localDirectory/filename.txt");
    InputStream is=url.openStream();
    BufferedReader in=new BufferedReader(new InputStreamReader(is));
    String line;
    while((line=in.readLine()) !=null) { System.out.println(line);
    ==========================================
    Of course, other data format would work in a similar way.
    Cheers,
    ljiang001

  • OBIEE 11g URL not working

    hi every one,
    I got a problem regarding my presentation services
    they are upend running and all the opmnctl files are all alive but my url is not working
    http://VAMSHI-PC:7001/analytics or any other em , console etc
    i waiting like 15min and tried the url dint work
    i tried by updating the GUID in NQSconfig and Instances but dint work...
    can anyone help me out with his..
    thanks everyone

    that means the services are not running. yes that can cause this issue. make sure you enter the right credentials and check everything is up and running fine. i think your weblogic is not running(managed server,admin server) once they are up and running then you can access weblogic console and em and from em you can start the BI services.
    hope it helps.
    Thanks,
    RM

  • UCCX: Silent monitoring is not working and recorded file is also not playing

    Hi,
    Running UCM 8.5 cluster with UCCX 8.5.
    In CSD, silent monitoring is not working.
    Windows XP OS is running on supervisor desktop. when i select the agent
    then the silent monitoring icon will highlighted once i click on the icon,
    after 5-7 seconds i am getting an error "Silent monitoring session has
    failed".
    Not able to playback the recorded files:
    I can able to record and the file size is 2.6mb for approximate 3min
    recording.When i tried to play from supervisor record viewer it is playing
    but no voice is coming. And i downloaded using play & save option and
    tried to play the .wav file but i can't hear any voice.
    Problem is while playing back the recorded file. I can able to see the
    recorded files in the UCCX.
    Please help me out!!!
    Thanks & Regards,
    Krishna

    It's likely the same problem: CAD is not forwarding packets to CSD or the CCX recording service. Two common causes for this are:
    The phone is not spanning to the PC port or does not allow PC Port VLAN Access. Change these options to true on the phone's configuration in CUCM.
    The NIC of the agent's PC running CAD is not processing 802.1q-tagged Ethernet frames. It must not drop these and pass them into the Windows NDIS stack for CAD to get them. Google is your friend here; this commonly requires registry changes to make the NIC process the packets.

Maybe you are looking for