If you're talking about a web application, you should use the getRealPath
from a ServletContext
object.
Example:
public class MyServlet extends Servlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException{
String webAppPath = getServletContext().getRealPath("/");
}
}
Hope this helps.