An image location problem

Hello everyone, I have written a few programs that load images,Objects etc. When I move one of these to a different computer, I have been resetting the String that specifies the directory where the images/Objects are stored manually. This got really annoying so I decided to work out how to make the program determine the directory itself. I tried this:
(in the class that loads the image)
String location = this.getClass().getResource("/myImage.png").getPath();
where the image is in the same directory as the class that loads the image. The problem is that URL's replace spaces with %20 which means when I try to create a File from the String the File does not exist.
I know that I can overcome this with a lot of class's such as ImageIcon as their constuctors can take URL's but I would still like to get a class's location in a String that is compatible with a Files constructor.
Any help would be appreciated

I'm unclear on how you're distributing your program to other computers, but if you end up with a structure like this:
%whereverUserInstallsItAndThereforeWorkingDirectoryIs%
  |
  --images
    |
    --player
    |
    --opponent
  |
  --soundsThen to load the file avater.gif in the player subdirectory of the images directory, you would want to get "images/player/avatar.gif." You shouldn't need to know where the working directory is or what it's name is or anything like that.

Similar Messages

  • Image location problem.

    Hi friends,
    I've put image and link object on my dashboard and link it to the image.
    I can see the image on my local system but cannot see the image there when I access the dashboard on some other computer.
    Currently I'm accessing the image from:
    C:\OracleBI\oc4j_bi\j2ee\home\applications\analytics\analytics\res\s_ABC\
    where s_ABC is my custom style folder.
    Thanks in advance

    Hi Madan, Appreciate your response.
    Yes I'm using custom Skins, and S_ABC folder is in both the locations.
    Can you please tell me what would come in image field in dashboard.
    http:/ ... url or fmap.
    I'm not aware about fmap. can you please tell me how to use it.
    Thanks in advance.

  • Dynamic Image Location in JRC

    <p>Hi !</p><p> </p><p>We are interested in using so called dynamic image location future in JRC. So far we are unsucessful, so the question is, is it supported in JRC ? We are able to get dynamic image location future working in report designer, but when our report is exported there is no image only path to it. </p><p> </p><p>We use Crystal Reports 11 R2, Java Reporting Component in JSP version.</p><br /><p>Mac</p>

    I have a couple of reports working with dynamic images. CR4E doesn't support this (yet?!?), but you can still do it with the JRC. The big kicker is the syntax of your URL. If you're using a static image on a server somewhere, it should work with no problem. However, if you're using a generated image, it's a little trickier. I discovered this when I was creating a report with barcode labels. The barcodes were not getting generated. I turned on debugging and found that the JRC was screwing up my url. The url was as follows http://myserver/barcode?message=12345 67890&format=datamatrix.
    In the logs, the JRC said it couldn't find an image at the url
    http://myserver/barcodemessage=12345+67890&format=datamatrix. It was stripping out the ? in the url, which is kind of an important character to say the least. I messed around with it and eventually found that if I just put ?? instead of ?, the image would display correctly with the JRC. Hope this helps! If not, post what version of the JRC you're using and the URL you're using for the image location.

  • Showing image located in km folder

    Hi, i'm trying to show an image located in a km folder, i do this binding source property of an image element to an string element in the context, and then i assign the path of the iresource to the context element.
        The problem is that when try to show the image it ask for a user and id, because it open it as a external link, its is posible to put in the source a relative path (i don't know if it fix the problem) or i must open the image and asign it by code? do you know any solution ?
    thanks

    i think that when access to the km need an user like that:
        IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
                     //establish resource context
                     IResourceContext resourceContext = new ResourceContext(ep5User);
                     //get a resource factory
                     IResourceFactory resourceFactory = ResourceFactory.getInstance();
    but when puts in the surce property of the image ui it try to open without login, if i copy a link to an image an try to open in a new window is the same.

  • Having a image alignment problem using clearbox

    Hi,
    I'm having an image alignment problem. I cannot figure it out. I'm using the clearbox - lightbox dreamweaver widget. Using Dreamweaver CS6.
    Actual page located here. Any help would be appreciated.
    http://dirtysouthink.com/gallery/dustin2.html

    This has very little to do with Dreamweaver. DW is merely a tool to assist you in building a web site. It is purely a matter of styling (CSS).
    When I look at the structure, I see
    BODY-CONTENT (width: 490px)
         GALLERY (width: 452px)
              CONTAINER (width: 500px)
                   ITEM (width: 150px)
    From this I can deduce that:
    GALLERY will fit inside BODY-CONTENT
    CONTAINER will NOT fit inside GALLERY or BODY-CONTENT
    ITEM will fit three times into CONTAINER
    To start with, I would reduce the size of the CONTAINER so that it fits inside of its parent. Then I would adjust the width of the ITEM so that only two of them fit inside of the CONTAINER.

  • I have LR5 on a mac book pro with a external hard drive with LR5 images. my problem is my external hard corrupted reformatedand have to this is expensive and i would to start over in LR5

    i have LR5 on a mac book pro with a WD external hard drive with my with my LR5 images . my problem is my external drive is corrupted .i was told by apple that my macshow the hard drive is there but it is not moumting and have to be reformat. i have to use recovery data to save my images on my external before i can refomat.iam willing to lose my images on my extenal hard drive but i would like to know can i erase my LR5 images and start over or delete LR5 and download it again

    Simply start a new catalog:
    File >> New Catalog
    Choose a new name and save.
    When the empty catalog launches you are ready to start over.

  • My iMac 27" Late 2012 has Image Persistence Problem

    I'm wondering what to do about an annoying image persistence problem on my 27" late 2012 iMac. I got the iMac just a few days ago. Monday actually, so 4 days ago.
    It's the 3.4GHz i7, 8GB, NVIDIA 680MX 1TB fusion drive model.
    Overall it has become the love of my life, but the image persistence thing is getting harder to ignore. This happens after only a few minutes of use. If I follow Apple's instruction on dealing with LCD image persistence, I can make it go away for a while, but it comes back very quickly.
    It is extremely noticeable on a plan dark background. It looks as thought he screen has been left on for a very long time with the same windows open, but it occurrs in less than 5 minutes of use with nothing more intense than a bit of web surfing.
    I've read that this is happening a great deal on these new iMacs, particularly teh 27" machines.
    While the problem seems to be known to those of us afflicted I don't know if Apple has acknowledged an issue or not.
    Here is a sample of the complaints: http://forums.macrumors.com/showthread.php?t=1509571
    I can make the ghost image vanish by bringing up an all white scree for a minute or so or using LCD Scrub.
    I'm wondering if anyone else has foun a solution other than asking for a replacement computer, which Apple seems to be granting on this issue?

    Avoiding image persistence on Apple (IPS) displays
    Avoiding image persistence on Apple LCD displays
    If you cannot resolve the issue yourself, then return the computer for a replacement. You may do this freely within 14 days from date of purchase, so don't delay.

  • Problem: codebase, jar and image reloading problem please help!

    Hi Java Gurus,
    I have written an applet that extends JApplet for viewing webcam. In order to reduce the download time I put my classes into a doorcam.jar file. The following is my <applet> tag in my html file.
    <applet code="CameraApplet.class"
    archive="doorcam.jar"
         codebase = "webcam/classes"
         width="375" height="475">
    <param name="imagePath" value="http://judge/webcam/images">
    <param name="webCamImage" value="door.jpg">
    <param name="COMPort" value="COM2">
    <param name="frameRate" value="10"> <!-- could not exceed more than 10-->
    <param name="host" value="judge">
    </applet>
    The fist problem is that my class file does not get loaded from the jar file if i provide the "codebase" attribute as above. Instead the browser load every single class file from the webserver. This has some problem too. Coz the browser sometimes just thorough NullPointerException or ClassNotFoundException. After much of debugging I found out that the problem is the IE browser which seldom fails to load classes or image file from the server. If i referesh the browser the applet and all its classes loaded successfully and runs smoothly. This behaviour never occurs when running with "appletviewer".
    I wanted all my classes to be loaded from my jar file. After much of trial and error I found out that if i remove "codebase" attribute the browser loads the classes from my jar file and applet loads very fast. This is where the second problem comes in. The browser does not reload my webcam image file so that the webcam become alive with live images, like before.
    If I run on "appletviewer" everything works fine my web cam is displayed properly. But in IE browser the image does not get reloaded when I refresh my image to give live to my webcam display. The refresh method is given below.
    private void refresh(final URL url) {
    Image webCamImage =getImage(url);
    webCamImage.flush(); // flush out the previous image
    webCamImage = getImage(url); // get a new image
    webCamImageIcon.setImage(webCamImage); webCamImageIcon.paintIcon(webCamLabel, webCamLabel.getGraphics(), 15, 15);
    When I add the "codebase" attribute back, the image gets reloaded for every refresh() and everything works fine. But the classes are also loaded from the server. And occasionally also suffers Class loading and image loading problem. As I presented earlier, when I do refreshing in the browser everything gets loaded and the applet function correctly with web cam displaying very well.
    The problem is so strange that I could not find any way to solve it.
    It would be a great help to me if somebody provide me some work around to the problem.
    I tested on Windows 2000, Windows XP, IE 5.5, IE 6 with J2SDK 1.4.0.
    Thank you all very much in advance.
    best regards,
    Judge

    Thank you so much for the suggestions. I did tried the way u suggested. The problem still the same.
    I think its the problem between IE browser and Java Plug-in.
    I which SUN would find these incompatibilities and solve these problems.
    I even tried using java SDK and plug-in 1.4.1 it even worst. It can't even load an applet. And it does not show any loading messages nor any error messages. It just show a cross sign on the upper left coner.
    I would be so glad, if Sun would try to eliminate the inconsistancies such as caching, loading, initializing etc between browser and its Java plug-In. For example, applets behave well in appletviewer and behave unpredictably in browser environment.
    I have seen so many people in the forums with all sorts of problems because of this.
    Right now I m desperately looking for work around to my problem.
    If somebody would provide me with the solution to my problem it would be a great help to me.
    thank you all so much.
    best regards,
    Judge

  • Extract Image in thrid-party System using Image Location

    Hi All,
    I am working in an Interface project. I need your help in one of the requirement.
    The data will flow from third-party system as an XML file and we are using Webservice to extract the data.
    The requirement is the third-party system will send the image location in the XML file and we need to extract the Image stored in the third-party system using that Image Location.
    Is this feasible and if so how?
    With Regards,
    Gurulakshmi

    Hi,
    No. We will store the image in Livelink(Third-party Storage Location) and attach that image against SAP Notifications which is created using T.code: IW21
    With Regards,
    Gurulakshmi

  • Acces images located on a static web applications

    HI everybody,
    I need to put images and html pages on IBM http server, I've created for that a web static application that I've deployed on the http server. I have also a dynamic web appliocation running on websphere 6 where I've puted all my jsp and servlets. I've instaled the IBM http plugin and both servers seems to be communicating correctly.
    my first question is: what is the best practices to access the images located on the webserver from my jsp files, I dont like the idea to use the full url:http://webserverIPAdress:port/staticContext/imagesFolder, is there a way to map the images folder path in my websphere application, or to tell the jsp page to go to the http server to lokup the image?????
    The second questions , do I need to do somethig to manage the redirection of the users requests: I'm planing to make my webserver as the front facade, I mean if a user asks for html page he will get it from the http webserver, but if he is requestiong a servlet how the request would be redirected to the websphere application????
    regarding the plugin if alredy installed it and i have performed the snoopServlets test comming with the IBM http server documention , it seems to be working fine, it means that both servers communicate well. so what the convenience of generation plugin functionality which is on the sever page on the websphere admin console????, do I need to that also???
    any kind of help would be appriciated , as you see I'm new with IBM servers.

    HI everybody,
    I need to put images and html pages on IBM http server, I've created for that a web static application that I've deployed on the http server. I have also a dynamic web appliocation running on websphere 6 where I've puted all my jsp and servlets. I've instaled the IBM http plugin and both servers seems to be communicating correctly.
    my first question is: what is the best practices to access the images located on the webserver from my jsp files, I dont like the idea to use the full url:http://webserverIPAdress:port/staticContext/imagesFolder, is there a way to map the images folder path in my websphere application, or to tell the jsp page to go to the http server to lokup the image?????
    The second questions , do I need to do somethig to manage the redirection of the users requests: I'm planing to make my webserver as the front facade, I mean if a user asks for html page he will get it from the http webserver, but if he is requestiong a servlet how the request would be redirected to the websphere application????
    regarding the plugin if alredy installed it and i have performed the snoopServlets test comming with the IBM http server documention , it seems to be working fine, it means that both servers communicate well. so what the convenience of generation plugin functionality which is on the sever page on the websphere admin console????, do I need to that also???
    any kind of help would be appriciated , as you see I'm new with IBM servers.

  • XSD Location Problem.

    Hi Gurus,
    After starting the node in a cluster environemnt, often receiving "Unable to load Translation schemas from for http://xmlns.oracle.com/BRM/schemas/BusinessOpcodes due to: XSD Location problem.
    XSD Loading problem."
    This is mainly observed in BRM schemas, has anyone exprienced this? what shall be the workaround/solution other than restarting the container/application?
    We are using SOA 10.1.3.4 MLR 8 and Oracle AIA 2.4.
    Please help.

    The BRM schemas are present in the AIA Components which will be referred by the load balancer url in a clustered environment. However, if in any of the nodes, the url for AIA Components has the local node url instead of load balancer url, this issue occurs.
    Identify the node which is giving the issue (shutting down one node at a time and retrying the operation which gives the error). In the node which has the issue, try doing a search on AIA components to find out if there is any reference using local node url instead of load balancer.
    If you find any, replace with the load balancer url. I had faced a similar issue and I was able to resolve it as I have mentioned above.
    Cheers,
    - AR

  • Storm9530 Location problem??

    Hi, i live in Canada and recently purchased a used and unlocked BB Storm 9530 off the internet from texas USA. I am using the phone Pre-paid for the time being and for some reason my calls I make are costing me a fortune. I live in a border-town with a US town right on the american side but since the phone is pre-paid it cant roam. Ive talked to my cell phone company about this and they said for some reason the phones is calling internationally and its not the service itself. The phone is manually selected for my home network and i just cant figure it out. is it because the phone is an american phone? is there any way of checking more into this because i cant even use my phone to call because $5.00 for a 15 second call is rediculous. please help!

    sherrdrew wrote:
    Does anyone know if Apple is ever going to fix the location problem.  I live in IL and my Ipad thinks I'm in NC.  I'm lucky though, searching the problem on the net I found most people who live in the US are having Ipad that think they live in Europe and Germany.  At least mine is on the same side of the world.
    What a totally ridiculous claim. Most iPad owners have no problems at all in this area. The fact that you are is invidual to you and your case and, absent any useful information at all in your two posts aside from "Hey, it ain't working ...", I guess we could guess that your problems are due to the fact that
    a. You don't have a 3G model, and therefore you don't have GPS, or ..
    b. You do, but it isn't working right, or ..
    c. You do, and it's working right, but PEBKAM, or ..
    d. You don't have a 3G model, and your iPad is unable to resolve the local WIFI data to generate a rough location, or ...
    e. Same as d. above, but the local wifi datafields are simply incomplete or incorrect, or ...
    f.  Yadda yadda yadda ......

  • SSRS indicator image display problem!!

    Hello ALL;
    I am having problem with displaying indicator image in DEV report manager. but same rdl works in QA environment. Both server has SP1 installed. Any Idea? Appreciate for your help. Thanks,

    Hi Techchi,
    Based on the limited information, I cannot figure it out for this issue. As per my understanding, I think this issue can be caused by the browser that run the report manager. If you use IE explorer to render the report, I suggest that you can try to run
    it in compatibility mode. If you are using another browser, I recommend that you should use IE explorer to render the report to check the issue again.
    If this issue still exists, in order to solve the problem more efficiently, I need to clarify some information.
    Are all reports with indicator image cannot render well in DEV report manager? Or just this one report?
    What is the phenomenon about the indicator image display problem? Could you please post a screenshot about this?
    It is benefit for us to do further analysis. Thank you for your understanding.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to solve the image display problem in the iTunes Store

    Hi guys!
    I just want to give a work-around for all of you having the image display problem in the iTunes Store. In my case only the square images in the slider sections won't load:
    I had this in my last W7-installation and got it again in W8 after the first few weeks.
    There are a lot of reports about this problem out there and adhoc solutions like 'clear the cache' or 'reinstall and drink ice tea' that do not work. It is obviously a file request error. It is all about finding out which server addresses get blocked by your computer.
    Solution: Go to your firewall and your Anti-virus-program. There must be a whitelist option. In Kaspersky, check the web-options, the banner-options and the firewall-options, because the all have whitelists. The following addresses have to be whitelisted:
    *.apple
    *.mzstatic.apple.com.akadns.net
    *.mzstatic.com.edgesuite.net
    *.da1.akamai.net
    *.itunes.apple.com
    se.itunes.apple.com
    upp.itunes.apple.com
    ax.init.itunes.apple.com
    xp.apple.com
    *.mzstatic.com
    client-api.itunes.apple.com
    www.apple.com.edgekey.net
    www.isg-apple.com.akadns.net
    Press Ctrl + R in the iTunes Shop then and browse throught the music sections. All images should be displayed correctly now.
    If not, there might be more Apple servers involved in your case. You can find them by running a DNS sniffing tool like the DNS query sniffer by Nirsoft or Wireshark.

    Phone restarting randomly could be loose battery. Tighten by putting a small strip of electrical tape on the back edge.
    THE BITTERNESS OF POOR QUALITY, LINGERS LONG AFTER THE CHEAPNESS OF PRICE, IS SOON FORGOTTEN.

  • Image reading problem in servlet

    Image reading problem in servlet
    I am reading an image in servlet and writing it to ServletOutputStream
    The following code works fine unless I change the size of the byte array (for increasing download speed) from 8 to something like 128 or any other higher value
    If I change the value of byte array size the image does not get downloaded properly, I mean the quality of the image changes, it does not looks like the original imageURL url = new URL("http://www.mysite.com/images/img1.jpg");
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    BufferedInputStream in = new BufferedInputStream(con.getInputStream());
    BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
    byte b[] = new byte[8];
    while(in.read(b) != -1)
         out.write(b);
         out.flush();               
    out.close();
    in.close();what do I change
    byte array size
    or use the constructor of BufferedInputStream with 2 parameter
    or use the constructor of BufferedOutputStream with 2 parameter
    or use flush outside while loop or what else

    Change your while loop to:
    int count;
    while((count = in.read(b)) != -1)
         out.write(b, 0, count);
         out.flush();               
    }The penultimate time read is called, it may not fill the entire byte array. You only want to write out however much was read into the array.
    For better performance, you should move the flush() outside of the loop too. BufferedOutputStream will flush automatically when its internal buffer is full.

Maybe you are looking for

  • MetaData information about views in a schema--Please help

    I want to access the metadata information about a view say,View1 in the schema schema1.How can this be done?

  • Question on processors?

    Hi all, New to Mac - Is the new macbook pro 13 inch **i5 processor** (lower priced model) faster than the last models 2.66 duo core (higher end)? Thanks for all your help.

  • All my songs are no "unchecked" -- Help !

    Somehow all the songs in my library became "unchecked". I can't seem to figure out how to execute a "Select All" and put the check marks back. Please don't tell me that I have to individually check 6,000 songs ! Thanks

  • Problem with mail attachments

    I have an xlsx file I have opened on my iPad and iPhone before, but it won't open on either now. If I go through Safari mail it works fine, how can I open it from my mail again? When I press on the downward arrow nothing happens. Thanks in advance

  • SAPRouter problem ERROR: sapserv2a: route permission denied

    Hello Gurus, we have a problem with connection with SAPOSS, when we test the connection present the following message: Connection Error Error when opening an RFC connection ERROR: sapserv2a: route permission denied (200.30.70.220 to oss001, sapmsOSS)