J
James
anyone can tell me how to get back the path of my current class that runnig?
James said:anyone can tell me how to get back the path of my current class that
runnig?
John said:I'm not sure about the original poster, but I am new to Java, and I have
wanted to do this on two separate occasion. In both cases I wanted to
reference files from the relative directory location of my classes. In the
first, I wanted to read a configuration file located in WEB-INF. My JAR was
located in WEB-INF\lib. I had to resort to passing a parameter to the
servlet, specifying the path to the config file.
In the other case, I had JUnit tests that loaded test data files. I wanted
to use a relative directory path to allow anyone to do a get from the root
of my project in version control, and be able to execute the tests without
setting up their environment.
Phil... said:What happens if say I am sitting in directory /usr/phil when I run
the program (that happens to live in /usr/bill)
via the console window "java ../bill/whereami"
what would be the result of getResource("./");
would it be /usr/phil or /usr/bill
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.