You can also use: AnyClassInSrcMainJava.class.getClassLoader().getResource("modules.properties")
On Thu, Mar 10, 2011 at 4:29 PM, Marek Šabo <ms...@buk.cvut.cz> wrote: > Hi all, > > I have a question regarding resource loading in general (sorry for little > OT). What code should I use to load a property file which is located in > src/main/resources folder (maven directory structure)? I tried various > snippets and the only one working for me under both tomcat (standalone) and > jetty (mvn jetty:run) is to load it like this (e.g. from Application class): > > URL url = > Thread.currentThread().getContextClassLoader().getResource("modules.properties"); > > I extracted this from log4j loading code - is this the only way or are > there other ways of doing this? The point being that files from resources > folder vary in different places when running mvn jetty:run, deploying war or > just running jar archive. > > Regards, > > Marek > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com <http://jweekend.com/>