How to load a properties from path that is relative to the classpath

Hello;
I need to load a set of properties from a propertie file from inside and EJB. I need to do so that I don't set the full absoulte path of the property file. In brief I don't want to be dependent on the file system struture instead I want to read the property file relatively to the package path name.
Here is my code:
package packagename.com;
import packagename.com.*;
import java.util.*;
import java.io.*;
public class PropDemo {
public static void main(String[] args) {
public static final String PROP_FILE_NAME
= "configuration.properties";
File inputFile = new File(PROP_FILE_NAME);
Properties prop = new Properties();
try {
FileInputStream fis = new FileInputStream(inputFile);
prop.load(fis);
} catch (Exception e) {
Any body have an idea how to so.
Regards
mal

I realize that you are trying to be a pain in the arseNot really. I know that I spent about a day figuring it out and that was after skirting around the issue for a about a year.
with that reply, but we can look here:
public void load(InputStream inStream) throws
IOExceptionReads a property list (key and element pairs) from the
input stream. The stream is assumed to be using the
ISO 8859-1 character encoding.
The original post suggests the author already knows how to load from a file. So this doesn't help at all.
And possibly GASP cross reference this entry in
Class:
public InputStream getResourceAsStream(String name)Finds a resource with a given name. This method
returns null if no resource with this name is found.
The rules for searching resources associated with a
given class are implemented by the defining class
loader of the class.
Now you may equivocate that the docs don't
specifically state that the classpath is where
resources are searched for, but I would maintain that
any Java developer worth anything should know this.Really? So where, in the above entry, does it explain the impact of the "/" character at the beginning of the string?
I know how classes are searched for. I know the impact of the class path. How that impacts a 'resource' is less clear. Particularily since the "/" character has nothing to do with loading classes.
>
This should be Java 101. Advanced Topics should be
something that affect people who have programmed Java
for years. (This is usually something that first year
programmers work out). If this is representitive of
the kinds of questions that qualify as "Advanced" then
this forum will become basically useless.So an opposing opinion...this is an advanced topic. Nothing in the java docs makes it clear. And it is even less clear the context of a container.

Similar Messages

  • How do you remove songs from library that were deleted through the finder?

    Hi All,
    I deleted several hundred songs through the finder, but they are still listed in the iTunes Library.  Is there any way to have iTunes scan for missing audio files and remove them from the list?  I can do it manually, but I was hoping there was a way for iTunes to scan for missing media.
    Thanks!

    Search Doug's AppleScripts for iTunes for something like "dead tracks", or just browse his scripts. You should find a script that will do this. I know that there were at least one or two, but I can't access Doug's site right now to get the exact names.
    Regards.

  • How do I stop Firefox from showing that little box at the bottom of every page every time I go from item to item on the screen. It is annoying and reminds me of Bing and all of those other interfering and annoying so called help features.

    No matter what site I am on Firefox wants to provide me information about the page or features. I do not want that. I just want to be able to look and move on. Although it is a little thing, I find it annoying and very controlling. I realize that there is no sense of privacy on the internet, but at least let me have that illusion. Furthermore, I hate things popping up while I am reading something. Let me make that choice, I do not need you to make that choice for me. Thanks.

    The easiest way is to use the Status-4-Evar add-on. With it you can choose to not display any of the status messages, or display them in the add-ons bar or location bar instead.
    https://addons.mozilla.org/firefox/addon/status-4-evar

  • How can i access properties from APP server through JNLP with ot using JAR

    Hello
    i want to retrive a Properties file from WL-7 app installed location like :bea/home/externalized.properties
    now i want to use this properties file throgh out the application. if any property is changed in "externalized.properties" that could be reflect dynamically in my code.
    So my requirement is :
    The current implementaion is using the JNLP down load the required code which contains the properties in .jar files, i have around 500 properties which are embedded in differnet .jar files with differnt property name. So i want to make all 500 properties to get out side from the jar files. and keep that consolidated properties in a single location and access it dynamically after deployed my ear file in wl7 app server.
    my application is implemented in SWING and EJB now i want to create an ear file which can be deployed any instance or cluster of WL7 app server.
    My Q:
    1. How can i access properties file through JNLP? (not a single property, want to access all properties in externalized.properties)
    2. is thare any known issue with SUN to load properties file through JNLP?
    your help is highly appreciated.
    -Siva

    Hey Thanks for your response,
    My question is Still not answered,
    see infact i have different type of environments to launch my application.
    infact my weblogic is deployed at remote location whihch is installed in linux,
    code is exist in our local system.
    At the time of code build for my local system i'm not able to get the properties from remote WL server,
    so at the time of code compilation and making the EAR file i'm not having this externalized properties file in newly generated EAR file.
    so once i copied my EAR in to WL7 cluster and i'm running the application using startAdminserver.sh, in this script file i'm defining the
    java -DexternalizedProperty=$WL_HOME/externalizedProperty.properties so now i'm able to get this properties to 'externalizedProperty"
    But when i download my application required jars, at this time i does not having the property file in my downloaded JAR files.
    So i want to access the remote properties file in suh sistuation.
    now i'm runnig the application at my local side to launch and Server side as well.
    So i have 2 runtimes 1 is my local and another is my server. In this case using "-DexternalizedProperty" i'm able to get this in server side,
    once control is come to local system it is not able to find this "-DexternalizedProperty" [externalizedProperty].
    Hope now u get my scenario..
    Thanks,

  • How do you delete songs from iphone5, that are not in your iTunes library on the computer?! I have the spot unchecked where it says show all music and I still have songs on my iPhone that I want gone, but they're not in my iTunes library...HELP

    I have a iPhone 5 with the most up to date software and I have songs appearing on my phone that I've deleted prior too from iTunes on the computer. How do I remove them from my phone, I've tried the left to right swipe and that just plays the songs! :/ Can anyone help me, I'd be forever grateful if I didn't have to go back to the store! I went I today abc he unchecked the show all music and there's still songs I don't want on my iPhone! :(

    The answer to the question in the title of the thread is yes, but it is not necessarily a good idea. At some point you are likely to find you need to restore your iPod for one reason or another, or it could be lost, stolen or damaged. If your songs aren't on your computer, and backed up too, then you will be less than happy.
    tt2

  • How can I delete an app from launchpad, that doesn't have the little cross in the left top corner. The app isn't an App Store app. The application is also not present anymore in my application's folder in finder.

    How can I delete an app from launchpad, that doesn't have the little cross in the left top corner. The app isn't an App Store app. The application is also not present anymore in my application's folder in finder.
    I tried to use the attached command through TERMINAL :
    sqlite3 ~/Library/Application\ Support/Dock/*.db "DELETE from apps WHERE title='Help';" && killall Dock
    sqlite3: Error: too many options: "DELETE from apps WHERE title='Help';"
    Use -help for a list of options.
    But i didn't work as I got the above error message.
    best regards
    Jeroen

    I'm in the same boat as you -- except that I manage both a school lab (volunteer job) and macs in the enterprise (pay job).  What I think we need is the Education Volume Purchasing Program
    http://www.apple.com/education/volume-purchase-program/faq.html
    Unfortunately this all seems a little rough around the edges -- for example, I have found updates for AppStore apps on the support.apple.com updates download site, but then when I install them via ARD they don't actually update the software.  (The AppStore icons still show as needing the updates, and the version info reports the old version.)  The documentation is also vague about which AppleID to use in which circumstance.  I think they just haven't finished thinking through the implications of the various procedures and policies upon the various kinds of customers.  When we deployed Mountain Lion on the school lab, we made an install usb and went around and installed it on each computer -- and it appears that you are on the honor system as far as paying for all of the licenses that you install.  We did!  But they appear to have no way to enforce it.
    So far, I have only deployed 9 Lion macs in my day job, and our "solution" to the AppStore showing updates problem has been to drag the AppStore icon off of the users' docks so they don't see them!

  • Can someone tell me how I load my music from my itunes account onto my new macbook pro??

    can someone tell me how to load my music from my itunes account on my iphone to my new macbook pro?

    See Here
    iTunes: How to move your music to a new computer

  • I've been deleting the info in the "Sort..." fields, but when I plug my iPod into my computer iTunes repopulates the fields I deleted.  How do I stop it from doing that?

    I've been deleting information I don't want in the "Sort..." fields (like getting rid of "Deluxe Edition" markers, etc.), but when I plug my iPod into my computer iTunes repopulates the fields I deleted.  This only happens for a few artists, and it's the same artists every time this happens.  How do I stop it from doing that?  It makes it measurably harder for me to control the organization of my library.

    Hi donfrommars,
    Welcome to the Apple Support Communities!
    Please use the following article for information and instruction on deleting the U2 album from your devices and account.
    Remove iTunes gift album "Songs of Innocence" from your iTunes music library and purchases
    Have a great day,
    Joe

  • When i play back an mp3 dj mix i,ve burn,t to cd in my car when i turn the engine of and then restart the car the cd starts back from the beginning how do i solve this problem so that when i turn the engine on end off the cd plays from the same place

    when i play back an mp3 dj mix i,ve burn,t to cd in my car when i turn the engine of and then restart the car the cd starts back from the beginning how do i solve this problem so that when i turn the engine on end off the cd plays from the same place it did before i turned the engine off

    It could be that the CD player will only playback "Redbook" CD's from the previous position.
    And starts mp3 type CD's from the beginnig.
    However.. it's not Logic related.
    pancenter-

  • How to load master data from SAP R/3 system like Customer master...........

    How to load master data from SAP R/3 system like Customer master, materioal master , vendor master.............

    Hi Bramha,
            Check ...........
    Re: master data loading in BI 7.0
    /message/4708129#4708129 [original link is broken]
    Re: Master data loading.
    Regards,
    Vijay.

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • I recently purchased two albums which iTunes (Apple) has buried in Mac cyberspace.  How do I synch my iPod so that I can download the two albums from iTunes onto my iPod

    I recently purchased two albums which iTunes (Apple) has buried in Mac cyberspace.  How do I synch my iPod so that I can download the two albums from iTunes onto my iPod.  Thank you from [email protected] in Oviedo, FL

    In iTunes sign out of your daughters Apple ID and sign in with your own.

  • Hi iv got a sky router downstairs and a time capsule up stairs how do i set it up so that it just extends the sky wifi and then the hard drive in the time capsule is accessible from all over the house thanks

    hi iv got a sky router downstairs and a time capsule up stairs how do i set it up so that it just extends the sky wifi and then the hard drive in the time capsule is accessible from all over the house thanks

    Connect an Ethernet cable from one of the LAN <--> ports on the back of the Sky router to the WAN (circle of dots icon) port on the back of the Time Capsule. This connection must be maintained at all times.
    Then, using the setup "wizard" on your iMac illustrated below, configure the Time Capsule to create a wireless network that uses the exact same wireless network name and password that the Sky router is using.
    You can get the setup wizard going in several different ways, but the simplest might be to click the WiFi icon at the top of the Mac's screen and then click on Time Capsule under the heading of New AirPort Base Station.
    The wizard will open up and analyze the network, then the suggest the correct setup. The example below shows an older AirPort Express that is about to be setup in the same way. You will see a Time Capsule icon on your screen when you run the setup wizard.

  • Why does the cursor keep going to the address bar and how can i stop it from doing that?

    For some reason after one of your updates, the cursor on the browser always goes to the address bar. It deletes the address and wants me to type in a search term. I have gone through the necessary changes that your support page suggested to turn that feature off, but it still does it.
    It is seriously irritating and inconvenient. How do I stop it from doing that. I am very close to not using Foxfire anymore as my default Browser. Please let me know how to fix this problem.

    For me at least, it's not a mouse setting.
    It started after an update a couple of months back and nothing I can do will change it. Tried running in safe mode, it does it, tried a reset, still does it. uninstalled, reinstalled, does it now too.
    It's infuriating!
    Currently running version 31.

  • How to load log4j.properties

    how to load log4j.properties file in my java code ?
    i have put log4j.properties in c:\property\log4j.properties directory.
    how do i load this properties file ?

    Normally you don't have to load it explicitely at
    all. Just place it in your classpath and use log4j,
    it should be loaded automagically.so, at run time i should use
    java -classpath .;c:\property\log4j.properties;c:\log4j.jar; MyClass
    is this the syntax ?

Maybe you are looking for

  • Deploying JSC Web App to SJSAS9

    Hi there, I have several web applications I've written in Netbeans, and they run on a SJSAS9 server. I've also written a JSC web app, and I would now like to deploy this onto the same SJSAS9 server that I've got my other web apps on. It is certainly

  • How to change the order of songs in a playlist?

    The order of songs in a playlist on ITunes is different than the order of songs on my IpodNano 7th Gen -- how can I get them to be the same?

  • Problem sending to Comcast email

    I am having a problem sending an email to anyone who is using comcast.net email.  This is something that just started about 3 weeks ago. I have a web site, if I send an email with the web site listed anywhere in the email, www.beaumontfamilyhistory.c

  • Oracle ADF Faces integrated in Oracle JDeveloper: Freebie?

    Hi room, I'd like to ask if Oracle ADF Faces, the version integrated in Oracle JDeveloper (this is a freebie) is a Freebie also, any1 knows, do share. Thanks a lot.

  • Big error in itunes 10

    After installing itunes 10, my computer got this problem: After 1h on the computer (itunes open whole time) there comes a strange noise from my 5.1 speakers and headphones, then the computer freezes (can't even move the mouse) this happend to me 2 ti