Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4235440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:29:59+00:00 2026-05-21T02:29:59+00:00

I have to use a library that accepts path to a directory and loads

  • 0

I have to use a library that accepts path to a directory and loads it via File(path);. What should be the path in tomcat webapp context ?

I always work with classpaths, but this API is really not thought through…

I don’t have experience with java execution context in tomcat, but it seems to me a bad idea doing something like this

System.getProperty("catalina.base") + "webapps/app/WEB-INF/classes/profiles"

Does tomcat provides java execution (AKA $PWD) path for resources in application context ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:30:00+00:00Added an answer on May 21, 2026 at 2:30 am

    Use ServletContext#getRealPath() to convert a webapp-relative path to an absolute disk file system path. Given your example, the following should do:

    String path = getServletContext().getRealPath("/WEB-INF/classes/profiles");
    File file = new File(path);
    // ...
    

    Note that this requires that the WAR is expanded, otherwise it will return null. Tomcat by default expands the WAR, but some other servletcontainers/configs don’t. Keep this in mind with regard to portability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever I have a library that use across different websites/ applications I've always just
Does anyone use have a good regex library that they like to use? Most
I have a C library that I'm planning to use in an iPhone application.
We have a Library Project that we use for all our central reused code
We have a database library in C# that we can use like this: DatabaseConnection
I have a library written in C that I would like to use in
I have to create a python (twisted) application that accepts connections from clients via
I have a c-library which I use in gcc. The library has the extension
I have a C++ library and a C++ application trying to use functions and
I have developed a simple library in Ruby and need to use this in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.