Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding path location on server returning null

 
Martin Russell Thorpe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic