The URL of ImageIcon(URL)

Hi all swing experts:
I want to fetch a image from some web page such as www.google.com/images/hp2.gif by using ImageIcon(new URL(http://www.google.com/images/hp2.gif");
But it can't work with java.lang.NullPointerException;
Why, and How to get it by other way?
Thanks in advance!

I want to fetch a image from some web page such as
as www.google.com/images/hp2.gif by using
ImageIcon(new
URL(http://www.google.com/images/hp2.gif");
But it can't work with
java.lang.NullPointerException;
Why, and How to get it by other way?where exactly do you get the NullPointerException?
try printing out the URL object (is this a typo or do miss the leading quote?) to see if you get something valid.
here is how i do it and it works fine:
URL gif = getClass().getResource(some_url);
...new ImageIcon(gif)...thomas

Similar Messages

  • How to change the URL of a URL-iView over Code ?

    Hi all,
    i am getting started with the Portal-Application-Developement and want to change the URL of an URL-iView on runtime with java-code.
    i have read the context and can get the Property url with this statement.
    endContext.getProfile().getProperty("url")
    But if i change this property, nothing is done.
    endContext.getProfile().setProperty("url", "http://www.yahoo.com");
    Where is my fault.
    Thanks for help.
    Regards Jürgen

    Hi,
    the context is of Type IPortalComponentContext.
    I cant find no method getParameter() at the context or the profile.
    The methods to read the properties of the URL-iView are
    context.getProfile().getProperty("url")
    context.getProfile().getAttributeValue("url")
    But if i want to set (change) this attribute, nothing is done.
    Regards Jürgen

  • Hyperlinks from my MSWord files suddenly don't work because "/FirefoxHTML\Shell\Open\Command" has somehow been added to the end of each URL.

    When I click to open the hyperlink in my Word file, the message I get in Firefox is "The requested URL /submissions.htmlFirefoxHTML\Shell\Open\Command was not found on this server." When I delete that portion of the URL, the website opens fine. What can I do to make the hyperlinks work properly?

    Thanks for the suggestion. I tried it, but it didn't work. The link information is written correctly on the MSWord page. But when I click on it and the Firefox tab opens, the page can't be found because "FirefoxHTML\Shell\Open\Command" has been added to the end of each URL. Might it help if I reset Firefox?

  • How do I pass the part of the url that matched url-pattern to JSP?

    Hello,
    I have a web app called ptest.war deployed in JBoss. In my web.xml I have:
    <servlet-mapping>
    <servlet-name>GetImage</servlet-name>
    <url-pattern>/images/*</url-pattern>
    </servlet-mapping>
    and:
    <servlet>
    <servlet-name>GetImage</servlet-name>
    <jsp-file>DoImageRequest.jsp</jsp-file>
    <load-on-startup>1</load-on-startup>
    </servlet>
    In DoImageRequest.jsp, I want to know what was requested by the user (so I can set some response headers and then re-direct to the image they requested), so if I go to:
    http://localhost/ptest/images/i1.jpg
    I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request object give me that string.
    request.getServletPath() returns "/images" and request.getPathInfo() returns "/i5.jpg".
    So do I need to construct what the user asked for by concatenating these two values?
    The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?
    Many Thanks,
    Paul Smith

    I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request >object give me that string.Even if you manage to construct that, such a request path would be intercepted by your jsp because it maps to /images/*.
    You would end up with infinite recursion.
    To circumvent that, you can change the folder that stores the image - call it something like img and then you just need append the request.getPathInfo().
    getServletContext.getRequestDispatcher("/img"+req.getPathInfo()).forward(req,res);
    The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that >without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?You could have a filter intercept all requests for *.img, add the response headers and pass the request along to the actual resource. That would be easier and more intuitive. If your web app has a good fronting like an apache web server, I think you can cache your images on the web server and set a property that would instruct the web server to set a no-cache header in response when it serves the image.
    ram.
    Edited by: Madathil_Prasad on Mar 26, 2010 7:20 PM

  • Could not retrieve the in-memory service URL after starting the in-memory.

    A local jvm process is discovered but mission control will not connect.
    Both jvm process and mission control are on the same host.
    Any suggestion?
    Thanks.
    This is the mission control help version:
    Oracle® JRockit Mission Control 3.1.0 (R27.6.3-40_o, 112101)
    I'm running mission control and a jboss web server on jrockit:
    $ java -version
    java version "1.6.0_11"
    Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
    BEA JRockit(R) (build R27.6.3-40_o-112056-1.6.0_11-20090318-2103-linux-x86_64, compiled mode)
    On linux:
    $ uname -a
    Linux isidore 2.6.27-11-generic #1 SMP Wed Apr 1 20:53:41 UTC 2009 x86_64 GNU/Linux
    This is the message that appears in the controlling tty window:
    Apr 24, 2009 9:55:43 PM com.jrockit.mc.browser.attach.LocalConnectionDescriptor tryJRCMDStyleStartingOfTheAgent
    SEVERE: Could not retrieve the in-memory service URL after starting the in-memory agent!
    Apr 24, 2009 9:55:43 PM com.jrockit.mc.browser.attach.LocalConnectionDescriptor tryJRCMDStyleStartingOfTheAgent
    Here is the exception in the dialog details:
    Could not open Management Console for [1.6] JBoss (5,474).
    java.lang.NullPointerException: null
    java.lang.NullPointerException
         at com.jrockit.mc.rjmx.ConnectionDescriptorToolkit.getHostName(ConnectionDescriptorToolkit.java:152)
         at com.jrockit.mc.rjmx.internal.RJMXConnection.setupServer(RJMXConnection.java:521)
         at com.jrockit.mc.rjmx.internal.RJMXConnection.connect(RJMXConnection.java:144)
         at com.jrockit.mc.rjmx.internal.RJMXConnectorModel.establishConnection(RJMXConnectorModel.java:111)
         at com.jrockit.mc.rjmx.internal.RJMXConnectorModel.connect(RJMXConnectorModel.java:154)
         at com.jrockit.mc.rjmx.ConnectionManager.innerConnect(ConnectionManager.java:95)
         at com.jrockit.mc.rjmx.ConnectionManager.connect(ConnectionManager.java:61)
         at com.jrockit.mc.console.ui.actions.StartConsole$1.preConnect(StartConsole.java:38)
         at com.jrockit.mc.browser.utils.PreConnectJob.run(PreConnectJob.java:74)
         at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

    After I posed the above, I saw that the url on the exception is munged.
    I didn't stumble over how to manually override that url.
    Instead, I added remote jmx capability to the process and added a connector. That is my work around.
    Thanks,
    John

  • With autocomplete turned on, I can no longer type "https" as the beginning of a URL

    I have used autocomplete in previous versions of Firefox and I was able to type "https" at the start of a URL, but now since I don't have any save domains that start with "h", autocomplete imediatley changes the "h" to a "p" which makes it impossible for me to type "https". I understand that I can hit "esc" after typing each letter, but that is crazy.
    I assume that Firefox now ignores the protocol portion of bookmarks and that is why this is happening.

    You can set the pref <b>browser.urlbar.trimURLs</b> to <i>false</i> on the <b>about:config</b> page to see the http: protocol.
    *http://kb.mozillazine.org/about:config
    See also this bug report:
    *[https://bugzilla.mozilla.org/show_bug.cgi?id=678352 bug 678352] - 'h' entered as first letter in location bar is overwritten with 'w' when browser.urlbar.autoFill is true
    <i>(please do not comment in bug reports)</i>

  • If I want to open the same website in a second tab and press Ctrl+T and start typing the website title or URL, why does Firefox 4 insist on switching to the first tab? Is it possible to turn this off?

    I regularly need to open the same website in two tabs, to be able to view changes made between opening the first and second tabs. In Firefox 3.x I could press Ctrl+T and start typing the website title or URL, which would be auto-completed by Firefox. This enabled me to quickly open the same website in a second tab. Firefox 4 does not do this, instead it wants me to switch to the existing tab. This is not what I need.
    Of course it is possible to open the same website in a second tab via e.g. a bookmark, but this takes more time and effort. It would be great if I could select Firefox's behavior in this situation.

    To create a duplicate of an existing tab in Firefox 4, do one of the following:
    *middle-click the icon on the left end of the URL/Location/Address Bar
    *hold down the Ctrl key and drag the tab until a small arrow appears at the border between tabs, then release the mouse button, then release the Ctrl key.
    <br />
    <br />
    You have multiple Java Console extensions because Java did not clean up after itself when updating; Firefox button > Add-ons > Extensions OR, using the Menu Bar, Tools > Add-ons > Extensions:
    *Java Console 6.0.17, Java Console 6.0.19, Java Console 6.0.20, Java Console 6.0.21, Java Console 6.0.22, Java Console 6.0.23
    Using the instructions here:
    *http://kb.mozillazine.org/Firefox_:_FAQs_:_Install_Java#Multiple_Java_Console_extensions
    you can delete the following folders:
    *{CAFEEFAC-0016-0000-00'''''17'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''19'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''20'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''21'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''22'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''23'''''-ABCDEFFEDCBA}
    You can leave {CAFEEFAC-0016-0000-00'''''24'''''-ABCDEFFEDCBA}
    <br />
    <br />
    '''You need to update the following:'''
    *Adobe Shockwave for Director Netscape plug-in, version 11.5
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.3"
    *Shockwave Flash 10.2 r152
    #'''''Check your plugin versions''''' on either of the following links':
    #*http://www.mozilla.com/en-US/plugincheck/
    #*https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #*There are plugin specific testing links available from this page:
    #**http://kb.mozillazine.org/Testing_plugins
    #'''Update Shockwave for Director'''
    #*NOTE: this is not the same as Shockwave Flash; this installs the Shockwave Player.
    #*Use Firefox to download and SAVE the installer to your hard drive from the link in the article below (Desktop is a good place so you can find it).
    #*When the download is complete, exit Firefox (File > Exit)
    #*locate and double-click in the installer you just downloaded, let the install complete.
    #*Restart Firefox and check your plugins again.
    #*'''<u>Download link and more information</u>''': http://support.mozilla.com/en-US/kb/Using+the+Shockwave+plugin+with+Firefox
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**SAVE the installer to your hard drive (save to your Desktop so that you can find it after the download). Exit/Close Firefox. Run the installer you just downloaded.
    #**Use either of the links below:
    #***https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox ''(click on "Installing and updating Adobe Reader")''
    #***''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''.
    #**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #**Note separate links for:
    #***Plugin for Firefox and most other browsers
    #***ActiveX for IE

  • How to set dynamic host name in the URL of a URL iView?

    Hello,
    I am using a standard URL iView that points to some J2EE app I've written and deployed on the same server.
    I would like to set the host name to be a dynamic one, this way I won't need to change the iView URL when transporting it from one portal to another. As far as I know the system for a URL iView only controls authorizations but cannot replace the full URL set in the iView.
    Any idea who can this be achieved?
    Roy

    Hi Mrityunjay,
    forced URL at runtime will require me to call the URL iView from another iView that I will need to code (setting the URL in the Request object). If I did all this I might as well call it from this iView already.
    I would like to do it with no further developments. I would have thought that SAP has constants that can be plugged in the URL for this type of thing, i.e. $hostname...
    Rgds,
    Roy
    Edited by: Roy Cohen on Aug 21, 2008 4:03 PM

  • How to list the content of a URL

    Hi All,
    I am wondering whether the method of listing the content of a URL, is the same as listing a directory on a local system? The listing of a local directory can be achieved with the following code for example:
        File dir = new File("directoryName");
        String[] children = dir.list();
        if (children == null) {
            // Either dir does not exist or is not a directory
        } else {
            for (int i=0; i<children.length; i++) {
                // Get filename of file or directory
                String filename = children;
    // It is also possible to filter the list of returned files.
    // This example does not return any files that start with `.'.
    FilenameFilter filter = new FilenameFilter() {
    public boolean accept(File dir, String name) {
    return !name.startsWith(".");
    children = dir.list(filter);
    // The list of files can also be retrieved as File objects
    File[] files = dir.listFiles();
    // This filter only returns directories
    FileFilter fileFilter = new FileFilter() {
    public boolean accept(File file) {
    return file.isDirectory();
    files = dir.listFiles(fileFilter);However, I am not sure whether it is as simple as replacing "directoryName" with "http://www.abc.com/photos" when using java.net.*.
    I am automating a task to download all photos in a gallery at certain website.
    Any assistance would be very much appreciated.
    Many thanks,
    Jack                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi paulcw, JoachimSauer,
    Thanks for answering to this post.
    I am only trying to automate some downloads of quite a of photo albums of relatives overseas. It only takes a few weddings to take hours to download. Moreover, the reason for having made the photos on the Internet so that the relevant parties can do their own download at their convenience for free as opposed to costing the individual to spend time and money on burn dozens of DVDs... After all, this is information age we are living in.
    Lastly, I am hoping to use the getContentType() method to determine the exact type of image such as jpg, gif, etc but doesn't appears that it is doing the right job. Is there any other way to do this instead?
    Thanks a lot again,
    Jack

  • URL portlet: ?How can I expose information in the place of a URL portlet in my page?

    Hello all:
    ?It`s posible to see pages (or others)in the place of my URL portlet?
    I'm working with EA in NT and I have a URL portlet published in a page. I can see the page refers by the URL portlet directly in my page, and it's OK for me. But when I try to navigate trough others "URL pages", Portal show me this pages in full Internet Explorer window (and now I don't see my page. Only the "URL page").
    Help me, please. And thanks.
    Arturo.

    Arturo,
    I think I understand what you are saying. When you click on links from within the URL Portlet, you leave your Oracle Portal page.
    The URL Portlet retrieve the content from a URL and displays it within a portlet window. All the URL links within this external page are active and have not been altered to work with 9iAS Portal. At this time, when you click on the links within the URL portlet you will leave your Portal page.
    Sue

  • How Can Hide The File Name in URL Using Jsp

    I Want source code for Hiding The File name in url address using jsp.
    for example www.website/login.jsp is view but i want www.website/ only.

    Hi Praveen - how does that DEF would be determined?
    Have a look at the below blog for executing os commands
    SAP XI File Adapter OS Command Line Feature - Process Integration - SCN Wiki
    XI/PI: Command line sample functions
    Is there any problem in using the dynamic file name configuration??
    Message was edited by: Hareesh Gampa

  • Find the folder of an url in bookmark management and try to modify it

    In bookmark section, how can i manage the folder of an URL (view , change, del) ?

    Your plugins list shows outdated plugin(s) with known security and stability risks.
    * Next Generation Java Plug-in 1.6.0_14 for Mozilla browsers
    Update the [[Java]] plugin to the latest version.
    *http://java.sun.com/javase/downloads/index.jsp#jdk (you need JRE)
    I'm not sure what you are trying to do.<br />
    Can you explain that better?
    See http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox

  • Please tell me what is the concept of GO URL

    Hi All,
    could you please tell me what is the concept of GO URL . coudl you please give me how can i use this ?
    Thanks in advance .

    you could try this link: http://oraclebizint.wordpress.com/2007/07/30/customizing-obi-ee-%E2%80%93-go-url-parameters/ of Venkat
    Edited by: Remc0 on Sep 9, 2008 9:36 AM

  • Track the progress of a URL loading

    I want to know the progress of a URL I load. The file is about 5mb. I create a new url :
    new URL ( "http://<the file>" );
    But I want to display a progress bar for the loading. How can I proceed, I don't know the file size (it can be 5mb, 6mb or 7mb).
    Any ideas ?

    This tutorial may be of some use:
    http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
    And, are you sure you don't know the file size? Tryint filesize = yourURL.openConnection().getContentLength();If this returns -1, then it's true that you don't know the file size. In that case all you can do is to display progress in terms of how many bytes have been downloaded. You have no doubt seen that yourself when you downloaded large files.

  • Where do i find the server name or URL?

    where do i find the server name or URL for my icloud account

    Why do you need this?
    Are you trying to setup your iCloud email on a non Apple Email client?
    If so:
    iCloud: Mail server settings for email clients - Apple Support

Maybe you are looking for

  • (Probably) A stupid playback question:

    I've recently (after purchasing a new PC) cleaned up my external HDs, and put my music collection onto iTunes, for use as a "media" player. I've had iTunes for many years, so, excuse me if this sounds remedial (I just cant figure it out): Why can't I

  • Mega 651 Fan Operations

    I am now looking for a utility program that will let me run the fan anytime the computer is on at preferabbly close to full speed. I have the unit in a cabinet which is open in front has a 3x3 hole on the right side and gives about  4 inches of clear

  • Why is there no sound with MPEG4s

    when I try to use videos from my Sony cybershot there is no sound in imovie... anyone know why this is? Thanks guys T

  • 10.1.0.4 bug workaround

    Our platform is Linux. After recovery finished and re-open database, instance down due to no temp file in temp tablespace. The problem is adding temp file requires DB open, but instance will go down in less than a couple of seconds. It's seemd this i

  • Batch Selection in Tcode LP12

    hello experts we are using release order parts to stage the material Tcode LP12 for Production in the LP12 screen the batch tab is deactivated ,can anyone tell me how to activate the batch field in LP12 tcode so that we can pick the batches in that s