How class.getResourceAsStream() is supposed to work?

here is what I am trying to do:
public class FileTest {
     public static void main(String[] argv) {
          //this opens the file, no problem:
          try {
               Scanner in = new Scanner(new File("myfile.properties"));
          } catch (FileNotFoundException e) {
               e.printStackTrace();
          //null here:
          InputStream is = FileTest.class.getResourceAsStream("myfile.properties");
The InputStream variable is null after executing the last line of code.
Documentations says that getResourceAsStream "Finds a resource with a given name..." But it looks like it doesn't. Am I having the wrong idea on how class.getResourceAsStream() is supposed to work?

It find resources in the classpath. If the "resource" you enter does not begin with a slant ( / ) then it "starts looking" in the same package as the class used to make the call. If it does start with a slant ( / ), then it "starts looking" at the varying classpath "roots", as amply explained in the API docs.

Similar Messages

  • How is wireless connectivity supposed to work for HP wireless printers?

    Does anyone know of any white papers, or similar, that describe how an HP  wireless printer is supposed to establish connection, 1) for initial setup, 2) for regular use after installation?  Trying to understand the process from experience, mine & others, without access to an analyser doesn't provide definitive answers.  It's a lot easier to solve a problem when you know how it's supposed to work . (and preventing them in the first place)
    Initial setup appears to use the IP address for establishing connection, but for subsequent use there would seem to be a number of ways that fit the behaviour .  Any pointers would be appreciated.

    Thanks TreeFrog. 
    My printer is a P1102w, and the support CD labelled P1100/P1560/P1600 series, so I guess any comment about the P1102w would be applicable to the 1560 & 1600s as well.  But it could also be useful to other printers with varying degrees of relevance.  Thats why I reckon a document discussing principles and ranges of devices they apply to could be useful (eg. "this method of connection was introduced in year x and not applicable printers before then, or something like that " .)    I also know that reading manuals is rare but I've found in the past that all sorts of useful interesting stuff can surface unexpectedly (the unknown unknowns of IT!).
    The specific question I have relates to sending a print after the initial connection has been established and Smart Install has been completed.  Do subsequent connections depend primarily on the IP address, or is some other method of identification used, such as MAC address or device id?
    If the IP address based on the dynamic DHCP request is used then this has implications in the event that the DHCP table on the DHCP service/router is reset, say in the event of a power or device reset.  Where such resets are frequent then it may be worth using an IP address determined some other way, such as a Manual(locked)-DHCP (if supported) or static (providing a static address outside the DHCP range can be found).
    Thanks for your help.

  • How application.cfc is supposed to work (AJAX & onRequest)

    I'm an intermediate CF developer using CF8 on a Windows 2k3 box.  We are using AJAX, and as such are using the following chunk o' code in the onRequestStart to ensure AJAX calls don't have issue:
    <cfif listLast( cgi.cf_template_path, '.' ) is 'cfc'>
      <cfset structDelete( this, 'onRequest' ) />
    </cfif>
    Everything is working fine, however, when I perform an AJAX call to a file that resides at: /framework/com/page.cfc  I get an error message that seems to be the application.cfc firing off from the com folder (located at /framework/com)  It states it cannot find the config.ini file in that folder, but the config.ini file is in the root, where the application.cfc is.  To load the config.ini, I am using:
    <!--- Get config file keys for application settings. --->
    <cfset lstKeys = evaluate( 'getProfileSections( getDirectoryFromPath( getBaseTemplatePath() ) & "\config.ini" ).#application.vars.environment#' ) />
    (The above code is where the error message references)  I'm told the app.cfc transcends down the folder path until another application.cfc is found (I'm not using others), so is the app.cfc running from the /framework/com folder?  is that why it's trying to find a config file at /framework/com/config.ini?

    I'm sorry if I mislead in my original message, but I am loading the config.ini in the onApplicationStart (this is why I'm confused as to why this code is executing again when I make my AJAX request - not only is it running onApplicationStart, but it's doing so assuming the now current location of /framework/com is the "root" (and it's not).
    Basically, every key in my config file becomes a variable and value in a structure called application.vars.  So if the config.ini has an entry of:
    absoluteRootURL=http://www.domain.com/folder
    Then I'll have:
    application.vars.absoluteRootURL (and it'll be set to 'http://www.domain.com/folder')
    I tested this by dumping in onApplicationStart, and the structure is created as expected.  I just can't figure out why onApplicationStart is being recalled during this AJAX.

  • Can someone explain how bin browsing is supposed to work?

    I am having trouble finding an easy way of browing my bins. I have footage separated into two bins, week 1 and week 2. Inside those bins is footage separated by day, i.e. day 1, day 2, day 3, and so on.
    I want to browse my footage in Icon View. However, double-clicking a bin opens it in a new tabbed window, which I then have to drag out of the way. If I want to go up a level, I can click the Up One Level button but then if I try to go back into a folder, it creates a new tabbed window again!
    I thought the bin window was one contained window inside which I could browse my footage. If I want to go up a level without creating a new tab when I open a bin again, I have to find the correct tab amongst the rest of them, often involving scrolling through the tabs that have exceeded the window width. All of this is incredibly time-consuming to the point where I'm wondering if I'm doing it wrong?

    Actually there are several ways to open a bin :
    To open a bin in its own floating panel, double-click the bin. This panel can be docked or grouped like any other panel.
    To open a bin in place, Ctrl-double-click (Windows) or Command-double-click (Mac OS) the bin.
    To open a bin in a new tab, Alt-double-click (Windows) or Option-double-click (Mac OS) the bin.
    If this didn't answer your question, check out more on this page from the Premiere Pro help.

  • How is Screen Saver Supposed to Work?

    Every time I bring Leopard out of screen saver my browser has closed and has to be restarted. Is this normal for MAC's or is there something I can do to stop this? I verified the display & HD are both set to never shut down. I also looked in power options and still nothing there.
    It really looks like it is restarting more than just going to screen saver. In fact now that I think about it the screen saver is gone and it just displays all the users on the machine.
    TIA,
    Brian

    Do you have the Screen Saver Hot Corners enabled? If not, go to System Preferences/ Expose' & Spaces...in the *Active Screen Corners* section, with the lower left drop-down button, choose "Start Screen Saver", and with the lower right drop-down button choose "Disable Screen Saver". This way you can start and disable it whenever you wish.
    Now with your browser open, manually start the Screen Saver for a few seconds, (move the mouse pointer to the far left lowest corner), now stop the Screen Saver w/mouse or keyboard.
    Did the Screen Saver activate or did the users list appear? Is you browser still open?
    Does the same problem exist for the other users or from a "Guest" account?
    Post back results.
    pw

  • How to make the default param work?

    Hi experts,
    When I define a default value for a parameter in a procedure or function, such as (p in     varchar2 default null), and when I call it without providing the parameter value, I am getting the "PLS-00306: wrong number or types of arguments in call to procname" error. How is the default supposed to work?
    Thank you.
    Ben

    Here is what I have,
    create or replace procedure CJIINGetBookingList (     
         p_LastName          in     varchar2,
         p_FirstName          in     varchar2,
         p_MiddleName          in     varchar2,     
         p_DOB               in     varchar2 default null,
         p_OLN               in     varchar2 default null,     --- DLN
         p_AddressCity          in     varchar2 default null,
         p_AddressZip          in     varchar2 default null,
         p_InCustody          in     varchar2 default null,
         p_Race               in     varchar2 default null,
         p_Gender          in     varchar2 default null,
         p_JailDateStart          in     varchar2 default null,
         p_JailDateEnd          in     varchar2 default null,
         p_ReleaseDateStart     in     varchar2 default null,
         p_ReleaseDateEnd     in     varchar2 default null,
         p_BkSearchResults     out     sys_refcursor
    Thanks.
    Ben

  • How to make the knowledgebase search work?

    This is not a FF problem; it is a problem with making the database search work properly. Example: trying to find the question "How do I install Addons for all users?" <http://support.mozilla.com/en-US/questions/745665>, I searched on "all users" with various combinations of "Add-ons" or "Addons" - coming up with many irrelevant hits (apparently not even corresponding to the search terms), but never with the page wanted. In fact, searching on the '''exact''' wording of the question "How do I install Addons for all users?" - with or without quotation marks - does not return the right page!! How is the search supposed to work?

    @the-edmeister:
    Ed, thanks for your reply, but in fact it is a reply to a different question - in fact, the question which, as I said, I was ''originally'' searching ("How do I install Addons for all users?"). That leaves two things to do:
    1) Since 50 users have already requested an answer to that question <http://support.mozilla.com/en-US/questions/745665>, would you please post your answer there? If you don't want to do that, may I do so? [It would be better if you do it, as you clearly know a lot more about the issue (and might be able to answer follow-up questions, of which I have at least one already).]
    2) We still need an answer to either:
    a) what is wrong with the KB search here or
    b) what is wrong with my search procedure?
    Thanks,
    John

  • I've searched to no avail for this problem. Similar posts but none that tell me what to do. I can't add or delete any bookmarks on my iPad 2 running the newest iOS. I know how it's suppose to work, it just isn't working!

    I've searched to no avail for this problem. Similar posts but none that tell me what to do. I can't add or delete any bookmarks on my iPad 2 running the newest iOS. I know how it's suppose to work, it just isn't working!
    It started after the major update to iOS 7.
    I can't believe that this is so hard to do. It's just not letting me. I can add a bookmark to the home screen just fine, just not in a bookmarks folder anywhere I try.
    I've used Apple products since 2001 and have always loved how intuitive they are. But the Safari browser since iOS 7 has been the worst I've experienced. At least right in the beginning after that update.
    I'd really appreciate any help that doesn't just tell me how it's suppose to work...I know that.
    My iPad 4 is not affected with the problem and works as it should.

    To delete, tap "Edit" (tap to enlarge image)

  • How are we supposed to work with the new motion tweens if there's no motion editor anymore?

    How are we supposed to work with the new motion tweens if there's no motion editor anymore? Without motion editor we can't see what kind of keyframes are set and we can't set any accelerations anywhere. Does Adobe now want us to go back and use the old motion tweens?

    Hi All,
    Flash Pro CC 2014 (v 14.0.0.110) is now available for download via the Creative Cloud App.
    We have included an all new Motion Editor along with several other new features with this release of Flash Pro. The new Motion Editor is completely redesigned, intuitive and easy to use while preserving the core functionalities and backward compatibility with Flash CS6
    To Invoke the Motion Editor, simply Double-Click on your Motion Tween span on Timeline (or Right-Click and select 'Refine Motion') and the Motion Editor opens up in-context in the Timeline itself. Double-Click again to collapse once you have made your adjustments.
    Complete list of New features in Flash Pro CC 2014 is available at these links:
    Overview:         https://www.adobe.com/in/products/flash.html
    Whats new:      https://helpx.adobe.com/flash/using/whats-new.html
    Release Notes: https://helpx.adobe.com/flash/release-note/flash-professional-cc-2014.html
    Videos:           https://helpx.adobe.com/in/flash.html
    Thanks,
    Nipun

  • Is this how pacman is supposed to work? (dependency "problem")[SOLVED]

    Hi
    Just did a fresh install of archlinux after buying a new computer.
    Installed some drivers.. kde (and some other stuff)
    Then.. just for the fun of it I removed qt3 with pacman -Rd.
    I was expecting that pacman -Syu would see that a dependency was missing and try to reinstall qt3.
    So I did a pacman -Syu, and what happened? Nothing.. pacman says all is okay, well all is not okay cus kde will not work without qt3.
    Is this how it should work or is this a bug? I checked the manpages for some kind of "install all missing dependencies" but found nothing..
    /Ivan
    Last edited by Fuel (2008-01-23 01:34:22)

    fwojciec wrote:
    That's not how Arch is supposed to work.  Arch is about giving power to the users.  With power comes responsibility, and this responsibility falls on the users in this case.  Remember -- this is a "do it yourself" kind of distribution and so if what I want to do is to screw up my system I should be able to do it in an easy, efficient and elegant way.  This is consistent with the mission statement of the Arch Linux project, this is how Arch works and this is why many of us love it.
    On a personal note, if Arch/pacman tried to hold my hand more, like you suggest it should, I'd be switching to another distro very, very quickly.
    It's not really about trying to get arch/pacman to hold your hand for you. It's more about giving the possibility to recover from a serious mistake. If you can tell me something wrong with adding an option wich checks for missing dependencies on your system and how that particular feature intervenes with "the arch way" - then please do.
    I'm not saying arch is bad, arch is actually the best linux distro I've used so far - but there is something common with almost all distros - you get dependency problems after a while, one way or another.
    Thats why I think there should be a way to resolve such issues.

  • How is PUSH *supposed* to work?

    I have just moved from a v1 iPhone to a 3G. I have had the 3G for 3 days.
    I'm trying to understand how the PUSH function works. The User Manual is not very clear.
    I'm using Mobile.Me
    I am not getting an alert when my phone is 'asleep'. Is this normal? (I would have thought the point of PUSH was that you are alerted when there is email .... )
    I can send myself a test, which is picked up pretty much instantly by my desktop Macs, but even if I leave the iPhone untouched for say 20 minutes, then wake it up, there is still no message. If I then go into the Mail app. (on the iPhone) it will then connect, download and alert me.
    This doesn't seem like the correct behaviour.
    Any explanations of how it is supposed to work would be most welcome.
    Grant Symon

    RomingGnome, Deggie, Thanks.
    I think what happened was that I had deleted my non-standard MM account on the iPhone, but then of course, when I did the first sync, it was replaced from the MM servers.
    I have now left this account on the iPhone, but turned it off, and made a new MM, standard account, which I then synced, did a test and it worked immediately, with alert, whilst the phone was asleep. Very very cool and just what I wanted.
    I shall now have to experiment to see if I can get the non-standard MM account to work too. All this because Apple won't let us use a non MM 'return address'. How dumb is that? Still ... one has to hope that with Apple trying to push the iphone towards enterprise, they might notice that [email protected] is not really the return address most business users are going to want.
    Thanks again,
    Grant

  • How is the "Private IP address" field supposed to work?

    I have been trying to forward port 25565 using an Airport Extreme. I know how to forward ports, and I know my IPv4 address is 10.0.1.2. The router (Airport Extreme)'s address is 10.0.1.1. However, when I go into the AirPort Utility and try to configure this, it gives me a field after "10.0.1.2" asking for some mysterious extra number on the end of this already complete address. It will not let me continue without filling this box out, but what do I put in it? ipconfig clearly shows that 10.0.1.2 is the extent of my computer's private IP. What do I put in this box? How is this supposed to work at all?
    Also, the "Browse..." button to the right of the mysterious field is utterly useless; it opens a window showing nothing in particular.

    Configuring port mapping on the Extreme typically takes two basic steps. Configuring the host with either a static or DHCP-reserved IP address, and then, assigning the appropriate UDP & TCP ports to the host.
    AEBSn - Port Mapping Setup
    To setup port mapping on an 802.11n AirPort Extreme Base Station (AEBSn), either connect to the AEBSn's wireless network or temporarily connect directly, using an Ethernet cable, to one of the LAN port of the AEBSn, and then use the AirPort Utility, in Manual Setup, to make these settings:
    1. Reserve a DHCP-provided IP address for the host device.
    AirPort Utility > Select the AEBSn > Manual Setup > Internet > DHCP tab
    On the DHCP tab, click the "+" (Add) button to enter DHCP Reservations.
    Description: <enter the desired description of the host device>
    Reserve address by: MAC Address
    Click Continue.
    MAC Address: <enter the MAC (what Apple calls Ethernet ID if you are using wired or AirPort ID if wireless) hardware address of the host computer>
    IPv4 Address: <enter the desired IP address>
    Click Done.
    2. Setup Port Mapping on the AEBSn.
    AirPort Utility > Select the AEBSn > Manual Setup >Advanced > Port Mapping tab
    Click the "+" (Add) button
    Service: <choose the appropriate service from the Service pop-up menu>
    Public UDP Port(s): <enter the appropriate UDP port values>
    Public TCP Port(s): <enter the appropriate TCP port values>
    Private IP Address: <enter the IP address of the host server>
    Private UDP Port(s): <enter the same as Public UDP Ports or your choice>
    Private TCP Port(s): <enter the same as Public TCP Ports or your choice>
    Click "Continue"

  • In Config OSPX, how does the 3 sorting logic supposed to work ?

    Hi MM experts,
    In OSPX, we have selection for "sorting" by Item-Table, Price, & Quantity. Can someone please explain how these 3 sorting is supposed to work ? Thanks.
    - Chetan

    Hi
    Please go thru the following link
    http://help.sap.com/saphelp_47x200/helpdata/en/52/884696aaae11d1b55c0000e82de955/frameset.htm
    Regards
    Ramakrishna

  • Iphone - brand newbie - how is the "SpeakHere" demo app supposed to work?

    When I run the app in the simulator, I can click the record button once, and nothing happens. The record button stays highlighted, the play button is never clickable, and nothing else happens on the screen. Would someone mind telling me what's supposed to happen so I can troubleshoot?
    thanks,
    -Morgan

    CornMuffin wrote:
    Is this how Find My iPhone is supposed to work? 
    Yep. Its not perfect, if that's what you're looking for & if Find My Phone was constantly pinging your phone's location to iCloud, you'd be measuring your battery life in minutes & once your battery ran down, well, that's the end of that.

  • How is the XMP workflow supposed to work between CS6 and LR4.1

    Can somebody please enlighten me ?
    I have a raw file in Lightroom, xmp files turned on.
    I open the file as a smart object in Photoshop.
    Back in Lightroom I do some edits, and to be sure, I save the edits back to the XMP.
    Back in Photoshop, no matter what I try, my edits are not picked up. I tried opening the smart object etc...but ACR does not pick up the edits I just made in Lightroom (even when the XMP file is up to date).
    If I resubmit the edited image from Lightroom, my edits are picked up, but this can't be the way it's supposed to work, can it ? What good is a smart object if you need to resubmit it each time...
    Isn't the XMP workflow supposed to be seamless between adobe applications, picking up any edit, no matter where the edit is made (from acr to lightroom and vice versa) ?
    I'm probably missing something, but would appreciate some help.

    Taking a little distance and looking at it from that angle, I can understand why it works the way it does now.
    Still, I feel there are some missed opportunities here.
    Compared to working between indesign and photoshop, when I have an indesign layout and I later edit the placed photoshop document, Indesign gives me a warning that my version is changed and I can update it to reflect the latest state.
    A similar thing could be done here inside photoshop "update to latest Lightroom edits" or something similar which could be totally optional for the end user to use or not.
    My confusion was mostly caused by the XMP files, it stuck in my head that these were external files holding all knowledge and no matter which Adobe program you used, it would work with those same xmp files... but I understood wrong apparently.
    I still have a lot to learn, thanks for all the answers, it is very helpfull.

Maybe you are looking for