Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Resource bundle class lookup

Thread view: 
michapringle@yahoo.com - 10 Sep 2007 18:55 GMT
Hi,

Sorry if this is a duplicate post...

I wrote a class that duplicated some functionality from the
ResourceBundle class, namely the ResourceBundle.getBundle method,
which loads a .properties file, from a directory provided by the JVM.

Example:
ResourceBundle configurationFileProperties =
            ResourceBundle.getBundle( Point.class.getName() );

The problem I run into is when I run my own code under tomcat. I think
the base directory provided by the JVM is .../webapp/WEB-INF/classes;
this is where the ResourceBundle knows to look, even if it isn't the
default directory specified by the OS. To make a long story short, I
think I can solve my problem if I can somehow get the base directory
specified by the JVM. System.getProperties doesn't seem to contain
this particular directory. I did look through the ResourceBundle
source, but no luck.

Can someone help me out with this? Thanks.

Please ask if there are any questions, or clarifications needed.

Cheers,
Micha
Lew - 11 Sep 2007 00:32 GMT
> Hi,
>
[quoted text clipped - 18 lines]
>
> Can someone help me out with this? Thanks.

I'm not clear whether you want to look in WEB-INF/classes or somewhere else,
and I'm also slightly confused by your references to ".../" and "webapp/",
which latter made me think briefly of Tomcat's "webapps" directory until I
figured that's probably (?) not what you meant.

If you actually want to locate your bundle in your app's "WEB-INF/classes/"
subdirectory, ClassLoader.getResource() or getResourceAsStream() may be what
you want.  You also can root yourself in the context root by using the
same-named methods of javax.servlet.ServletContext.

Signature

Lew

michapringle@yahoo.com - 12 Sep 2007 22:20 GMT
> michaprin...@yahoo.com wrote:
> > Hi,
[quoted text clipped - 32 lines]
> --
> Lew

Hi Lew,

On re-inspection of the ClassLoader javadoc, I think is what I want.

Cheers,
Micha
michapringle@yahoo.com - 12 Sep 2007 22:22 GMT
> michaprin...@yahoo.com wrote:
> > Hi,
[quoted text clipped - 32 lines]
> --
> Lew

Oh, forgot to say thanks :)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.