Loading an image from an arbitrary URL without using an ImageIcon

Can anybody maybe point me in the direction of other (as in harder-to-use, but more flexible) ways to load an image from a URL?

Interesting results:
When I run this test code (the names have been changed to protect the innocent):
package graphicstest;
import javax.swing.*;
import java.net.*;
import javax.imageio.*;
import java.awt.image.*;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2007</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
public class Foo
    extends JFrame {
  static ImageIcon ii;
  public Foo() {
    setSize(200,200);
    try {
      System.out.println("2=aborted; 8=complete; 4=errored; 1=loading");
      ii = new ImageIcon(new URL("http://intranet/part?FOO.JPG"));
      System.out.println("image load status: " + ii.getImageLoadStatus());
      getContentPane().add(new JLabel(ii));
      System.out.println("image load status: " + ii.getImageLoadStatus());
    }catch(Throwable t) {t.printStackTrace();}
  public static void main(String args[]) {
      Foo foo = new Foo();
      foo.setVisible(true);
      if (ii.getImageLoadStatus() == 4) {
        try {
          BufferedImage bi = ImageIO.read(new URL(
                "http://intranet/part?FOO.JPG"));
          ii.setImage(bi);
          foo.validate();
          foo.repaint();
        } catch(Throwable t) {t.printStackTrace();};
}. . . from a box that's not on the VPN, it blows up at the ImageIO.read() call (not unexpectedly). But if I run it from a box that's on the VPN, and able to access the URL, then it returns just fine from the ImageIO.read(), and I get a null pointer exception at the call to setImage().
Clearly, this is trying to tell me SOMETHING, but I don't quite know WHAT.
JHHL

Similar Messages

  • How to load master data from 2 source system without using 0logsys as compo

    Hi Gurus,
    I am working on a project which has 2 source systems.
    Now I have to load master data from 2 source systems without making 0LOGSYS as compunding attribute. Because all the objects which i want to use compunding attribute are reference objects for lot of other info objects. So, i dont want to change the business content objects structure.
    So, please help me out providing logic.
    thanks in advance
    Peter.

    Hi Peter,
    Can you brief me how did you resolved your issue?
    Regards
    Utpal

  • JAVA, sqlserver - Need to load an image from the sql server database

    hi,
    I need to load an image from the sql server database using java. I have connected to the database and getting all other records except the records for a photo (datatype = LONGVARBINARY) and Remarks (datatype = LONGVARCHAR).
    I am using java and sql server db. The photo and remarks are stored in the db. and i need to show the image and the remarks fetching them from there.
    I get the error :
    Thread-9 org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
    How can I achieve this?
    Thanks,
    Gargi

    Exactly. And are you using MySQL?
    No. You are using Microsoft SQL server if I have to believe your initial post. A quick google tells me that the dialect class to use is:
    org.hibernate.dialect.SQLServerDialect

  • Loading an Image from the database and display it on browser

    I do not know if this is even possible.
    At the moment, to load an image inside an Html page you need to use the <img src=""> tag. and in the src you put the path of the image. Now I would like to save an image inside the database.
    An option to still display the image on the browser would be that my service object, would load the object from the database (saved as blob) then save it somewhere on the Server, and the still use the <img> tag to load the image from that location.
    However I was wondering wheather there is another way to do it without saving this image on the server. that is loading the bytes from the database (or a location on the server) and provided these bytes to the jsp page to display the image.
    Is this possible? or?
    regards,
    sim085

    hmm ... ok .. that sounds good .. but that means that
    a servlet must exsist at all time to display the
    required image.Servlets are usually instantiated by the servlet container upon an incoming request.

  • Error While loading a image from database

    Purpose
    Error While loading the Image from the database
    ORA-06502: PL/SQL : numeric or value error:Character string buffer too small
    ORA-06512: at "Sys.HTP" ,line 1480
    Requirement:
    I am developing the web pages using PSP(Pl/sql Serverpages) . I have a requirement to show a image in the webpage. I got the following procedures from the oracle website.
    I have created the following table to store the images
    create table DEMO
    ID INTEGER not null,
    THEBLOB BLOB
    And I also uploaded the Images. Now I am try to get a image from the table using the following procedure .But I am getting the error message line 25( htp.prn( utl_raw.cast_to_varchar2( l_raw ) );) .at it throws the following error messages
    ORA-06502: PL/SQL : numeric or value error:Character string buffer too small
    ORA-06512: at "Sys.HTP" ,line 1480
    Procedure that I used to get the image
    create or replace package body image_get
    as
    procedure gif( p_id in demo.id%type )
    is
    l_lob blob;
    l_amt number default 30;
    l_off number default 1;
    l_raw raw(4096);
    begin
    select theBlob into l_lob
    from demo
    where id = p_id;
    -- make sure to change this for your type!
    owa_util.mime_header( 'image/gif' );
    begin
    loop
    dbms_lob.read( l_lob, l_amt, l_off, l_raw );
    -- it is vital to use htp.PRN to avoid
    -- spurious line feeds getting added to your
    -- document
    htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
    l_off := l_off+l_amt;
    l_amt := 4096;
    end loop;
    exception
    when no_data_found then
    NULL;
    end;
    end;
    end;
    What I have to do to correct this problem. This demo procedure and table that I am downloaded from oracle. Some where I made a mistake. any help??
    Thanks,
    Nats

    Hi Satish,
    I have set the raw value as 3600 but still its gives the same error only. When I debug the procedure its throwing the error stack in
    SYS.htp.prn procedure of the following line of code
    if (rows_in < pack_after) then
    while ((len - loc) >= HTBUF_LEN)
    loop
    rows_in := rows_in + 1;
    htbuf(rows_in) := substr(cbuf, loc + 1, HTBUF_LEN);
    loc := loc + HTBUF_LEN;
    end loop;
    if (loc < len)
    then
    rows_in := rows_in + 1;
    htbuf(rows_in) := substr(cbuf, loc + 1);
    end if;
    return;
    end if;
    Its a system procedure. I don't no how to proceed .. I am really stucked on this....is their any other method to take picture from the database and displayed in the web page.....???? any idea..../suggesstion??
    Thanks for your help!!!.

  • How do I import images from my hard drive without losing resolution? My original files after import are significantly smaller. What should I do?

    How do I import images from my hard drive without losing resolution? My original files after import are significantly smaller. What should I do?

    Hi Keith, and all others chiming in, I do have the correct option checked in advanced settings telling iPhoto to copy the images into the library. What is a refernced library? Perhaps this is where I am getting confused. I exported my entire photo library from an old iMac5 to my external hard drive, from there I attempted to import the entire library to my new iMac. Am I overlooking an obvious and easy way to import from the hard drive to the new iMac--I dragged the entire photo pholder from the hard drive to the open window of iPhoto on the new computer. Now, I only get preview file sizes in iPhoto, unless I have my external drive open. Perhaps I need to import the original images from the hard drive in a different way...?! (This is making me feel pretty stupid.)

  • Stream-in images from client to server,without running the transmit code

    Hello all,
    Im using JMF for my current project.Right now,I am trying to only recieve images from the client without the client transmitting it.That is I dont want the transmit code to run on the client.
    I should just be able to stream in the images from client to server, without running the transmit code on client.
    Can this be done?
    Thanks in advance

    suppigs wrote:
    Can I know more about this?Sure.
    <Side A>
    You'd just need to write an application that doesn't have a GUI (so, a console-based application) that listens on some pre-determined port for a message to start broadcasting. Maybe you'd send it the IP/PORT number to start broadcasting on. Once it receives that message, it'd start broadcasting the web cam to the IP/PORT number until it received a message to stop. Once it stops, it'll just go back to waiting for the next "start" signal.
    <Side B>
    On the other side, you'd write an application that sends the start messages, receives/displays the videos, and then sends the stop signal. This will have a GUI, and be your "control program" so to speak.
    Then, once of have both of those programs working...if you're using Linux, you're done. If you're using Windows, you'd need to modify the <Side A> program so that it can run as a Windows service.
    There are a lot of ways to do this, you can google it or look at the following link:
    [http://twit88.com/blog/2007/09/19/open-source-software-to-start-up-java-as-windows-serviceunix-daemon/]

  • Load multiple images from directory?

    What is the best way to use CF to load multiple images from a
    server directory please? I have CF calling a stored procedure that
    returns an array of file names. I am using a Flex front end, and
    wonder if I should just pass the file name array to Flex and let it
    loop through and load each image into an array. Or is it possible
    from within my CFC to use the file name array to get CF to grab the
    images and then pass that image array back to Flex? If so, is there
    any advantage to either approach? TIA,
    Mic.

    You don't want to pass the binaries to Flex, you should just
    give Flex the image names and load them via HTTP.

  • How can I best load RAW images from a Canon SX50?

    How can I best load RAW images from a Canon SX50?

    9Sorry, ........confused about this process.   When I attempted to Post the question I had entered, I was told a blank space could not be posted.  So, I reentered the Q in the "space"........ which apparently was the space for an answer....!! ??......)
    >  When I try to load RAW images taken by my Canon SX50 from the SD card, iPhoto 11 -  (iMac/OSX 10.6.8) tells me that it can't read the format or something like that.    OSX 10.6.8 came out before the SX50, thus, did not include the related program.           I want to shoot RAW on the SX50....... but I then want to load them into iPhoto....... which I do directly from pics I take with my Nikon D200.  
    Not sure if this will help.............

  • I can't down load my images from my Nikon D4 to Apeture.

    I can't down load my images from my Nikon D4 to Apeture.

    Hi skhart1998,
    I also use Nikon D4, D2H and D2Xs
    I use Nikon Transfert 2, the latest version, to download my shots to my MacBook Pro hard disk in a picture folder. After this I use Aperture Import to place the New folder created in the Nikon folder in the Aperture Inspector folder... This way, I always have the copy of my originals files.
    .jpg or .nef  work fine.
    Denis

  • Loading realscale image from memorycard.

    Hi.
    I made a big image (3550 x 2100 pixels), which my Nokia 6125 didn't zoom enough on the normal Picture preview.
    So I decided to make a program for it, so I could see all the details from the pic, and move around on the image. (Like zoom, but I need to get closer.. )
    First problem i encountered, was that 4mb application was too big to install on my memorycard... Darn limits...
    So I decided to add them seperately, that I'd load the image from the application.
    Well when I ran the "File Browser", there was 3 things:
    - ".." (Folder up)
    - "E:\" (crashes, no access)
    - "C:\" (crashes, no access)
    So any ideas how could I get it work properly?
    Thanks!

    hmm ... ok .. that sounds good .. but that means that
    a servlet must exsist at all time to display the
    required image.Servlets are usually instantiated by the servlet container upon an incoming request.

  • Problem creating an image from a remote url

    I am creating a servlet which does the following:
    1. retrieves an image from a remote url
    2. resizes the image
    3. sends the image to the client.
    The servlet works fine when I run it on my PC, but when I run it on the server, it doesn't. Here's the problematic code
        private Image getRemoteImage(String imageUrl) throws Exception {
            System.err.println("in getRemoteImage()");
            if (!imageUrl.startsWith("http://")) imageUrl = "http://" + imageUrl;
            URL u = new URL(imageUrl);
            System.err.println("imageUrl: " + imageUrl);
            HttpURLConnection huc = (HttpURLConnection) u.openConnection();
            huc.setRequestMethod("GET");
            System.err.println("connecting...");
            huc.connect();
            System.err.println("Getting DataInputStream...");
            DataInputStream in = new DataInputStream(u.openStream());
            //DataInputStream in = new DataInputStream(huc.getInputStream());
            System.err.println("...got");
            int numBytes = huc.getContentLength(); //1063
            System.err.println("numBytes: " + numBytes);
            byte[] imageBytes = new byte[numBytes];
            System.err.println("reading fully...");
            in.readFully(imageBytes);
            System.err.println("...read");
            in.close();
            System.err.println("creating imageIcon");
            ImageIcon imageIcon = new ImageIcon(imageBytes);  //   <-- problem here
            System.err.println("** THIS LINE IS NOT REACHED **");
            System.err.println("creating image");
            Image image = imageIcon.getImage();
            System.err.println("returning image");
            return image;
        }When I access the servlet with FF, the browser reports:
    The image �<my servlet url>� cannot be displayed, because it contains errors.
    When I access the servlet with IE, I get:
    Apache Tomcat/4.0.3 - HTTP Status 500 - Internal Server Error
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429)
         at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
         at java.lang.Thread.run(Thread.java:534)
    root cause
    java.lang.NoClassDefFoundError
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at java.awt.Toolkit$2.run(Toolkit.java:748)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:739)
         at javax.swing.ImageIcon.(ImageIcon.java:205)
         at myservlets.GetImage.getRemoteImage(GetImage.java:283)
         at myservlets.GetImage.processRequest(GetImage.java:73)
         at myservlets.GetImage.doGet(GetImage.java:394)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429)
         at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
         at java.lang.Thread.run(Thread.java:534)
    Any ideas?
    Cheers,
    James

    Cheers rebol.
    I've tried that (along with all other kinds of techniques I never knew existed). I think it might be a problem with the Tomcat setup - it may need to run headless (sounds a bit severe!...).

  • Loading an image from CameraRoll - how long should it take ?

    Hi All
    I'm loading an image from the CameraRoll using this method http://www.flashandmath.com/mobile/cameraroll/
    Now on my iPad2 the image loads pretty instantaneously
    However on my iPhone4 it takes approx 8 seconds for the image to load.
    ( The time is taken after calling loader.loadFilePromise waiting for Event.COMPLETE ... i.e. the image to load )
    function onImgSelect(event:MediaEvent):void {
    var promise:MediaPromise = event.data as MediaPromise;
    removeBrowseListeners();
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
    loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, onError);
    loader.loadFilePromise(promise);
    The code base is the same. There are (at least) 2 differences :-
    1) The hardware (iPad vs phone)
    2) The number of images on the camera roll (approx 60 on iPad vs almost 900 on the phone)
    Has anyone else noticed such a difference in speed between devices / number of files ?
    Is there a better/quicker way to load an image from CameraRoll ?
    Is 8 seconds normal/acceptable (I show a busy indicator)
    Any help / suggestions/ observations most appreciated !

    If you opted for the Secure Erase and the account has a lot of data in it, then it could take days to complete.

  • To load the image from appl. server to FORM

    Hi all,
    i have to fetch the image from Application server and Print in a form. i don't know how to load the image from appl. server to FORM.Through SE78 i guess we can load the image only from presentation server,,,,can anyone help on this????

    Hi Bhuvaneshwari ,
    Through <b>SE78</b> you can fetch the image from application server.
    Goto><b>Graphics</b>><b>BMAP(Bit map images)</b>>In <b>Name</b> parameter click <b>F4</b> for input help.>click on <b>execute</b> button.
    These images are stored on document server.
    There you can find images of application server.
    Those images you can import.
    Reward if helpful.
    Regards,
    Sandhya.

  • Firefox won't load check images from my online bank.

    Firefox won't load check images from my online bank. It had been doing so with no problems, but stopped 2 days ago. I can get into my account and navigate with no problems. But when I click to see the image of a check, I get a blank page.
    I am using Firefox 3.6, but I have the same problem on my laptop with Firefox 4
    It works fine with Safari and Internet Explorer.

    If you can't open them in Firefox anymore (you seem to have a plugin: View PDF documents within your web browser) then download the documents to the desktop and open them with a program that can open PDF files.
    See also to be sure that that plugin is still selected:
    * https://support.mozilla.com/kb/Managing+file+types
    Do you otherwise have problems with PDF files?

Maybe you are looking for

  • Soap attachment in jaxws

    hi i am trying to add an attachment to a soap message . im using jaxws2.0 and this is a snippet of my code.. public boolean handleMessage (SOAPMessageContext messageContext) {           boolean request = ((Boolean) messageContext.get(SOAPMessageConte

  • This AM iPhoto won't open...says locked disk or I don't have permission to repair?

    Iphoto will not open.....Drop down box "locked disk or I donot have permission to repair iphoto"????

  • [SOLVED] Can't connect to internet after installation

    Hello, I just installed Arch, and during the installation I connected to wifi (obviously, since I had to download the packages) with iwconfig and all the other tools on the installer, but after the installation I wasn't connected any more. I have no

  • XML to XSL

    I am strugling to output my xml document in an xsl format. My xml document is created in a function, and I have another function that takes the xml and transform it to an xsl document... something is wrong somewhere the output to xsl is not happening

  • Does Java EE 6 support JMX2.0 ?

    I am planning to use JMX in my future Java EE 6 projects. Still in research for now, I'm afraid I've got a little confused by the versioning issue. According to [Java EE 6 Technologies|http://www.oracle.com/technetwork/java/javaee/tech/index.html] pa