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 8333039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:53:23+00:00 2026-06-09T02:53:23+00:00

I have two project where one is depended on the other, i.e. project A

  • 0

I have two project where one is depended on the other, i.e. project A depends on project B, and the two projects reside in different directories.

In the independent project, i.e. project B, there is a class which holds a code that tries to access directories and files with respect to independent project directory. Since the depended project, i.e. project A, instantiate an object from the independent project, when the object execute System.getProperty("user.dir") it returns the execution directory, i.e. the directory of the dependent project; the same holds for new File(".").getAbsolutePath().

I would like to solve the issue in generic way, i.e. I wish to avoid the need to pass as an argument the path, rather, I wish the use relative directories programatically.

Any guidance\clues?
P.S. not sure if it is relevant, but I am using Eclipse as my IDE.

UPDATE
This should hold…

final String clsName = getClass().getName() + ".class"; 
System.out.println(getClass().getResource(clsName));
  • 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-06-09T02:53:24+00:00Added an answer on June 9, 2026 at 2:53 am

    I’d use the class-loader instead of using paths directly. In eclipse, and in an deployment situation both projects resources should be in the classpath.

    ProjectA
        example.png
    ProjectB
        foo.txt
    

    Something like this should be able to load a resource from either project A or B.

    URL url = getClass().getResource("/example.png"); // get URL
    InputStream stream = getClass().getResource("/foo.txt").openStream(); // open a stream
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two projects.One project is build in MVC asp.net and the other project
I have two projects which the RestKit framework . One project works without problems
I have two project, one which generates some artifacts from a WSDL file using
I have two projects configured identically for log4net. One project logs fine; however, the
I have several projects open in an Eclipse workspace. Like so: com.harbl.project.one com.harbl.project.two com.harbl.project.three
I have a solution with two projects. One for project for the production code
I'm using eclipse, and I have two android projects which have different topics. And
okay so I have two projects one in which I have done all the
I have two Android projects in Eclipse. I copied the one project from the
I have two projects, one project loads files from the project folder, one project

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.