Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding path location on server returning null  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am running a class on an application server and trying to find a relative path so I can load a file from within my Java class.

I have been investigating using this.getClass().getResource("../") and get the location of the running class, which is good, but when I try to navigate up the tree I can get so far and then I get null.

For example

Note that testF jumps from the classes dir to properties for some reason and then testG returns null.
What I want to do is get to myappwar directory. note this is not a servlet

Is this the correct approach or should I use some other way?

Thanks for reading
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!