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

I was given an static library (.a extension file) that I have to use
I have a graph library that I use to plot some data. This data
I have a C library that I'm planning to use in an iPhone application.
I have a WinForms application that makes use of a TaskDialog library that leverages
We have a Library Project that we use for all our central reused code
Good day, I have a library project that i use to create a paid
I'd like to use the MSHTML library to parse some HTML that I have
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
Unfortunately, I have to use a C library with internal state in my Android

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.