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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:47:03+00:00 2026-05-25T16:47:03+00:00

so I have a pretty large project in Eclipse which runs fine and accesses

  • 0

so I have a pretty large project in Eclipse which runs fine and accesses files etc. And when in Eclipse I access files with a local directory name in relation to the root of the project directory.

So my project is called “Project1” for example and is inside a directory called “MyProjects” so it looks like this: “MyProjects/Project1”. I want to access a file in the “MyProjects” folder called “hello.text”. So I just do “../hello.text” and it works fine when I do this in Eclipse.

The problem I have is when I run the program using the command using “java Project1” it runs the program fine but it cannot access that file because when executing programs from the command line it stars them from the “bin” directory which is inside of the “Project1” directory. So it messes up the whole program. Is there anyway to change this easily in my Windows environment or Eclise? I hope my question makes sense. I want the program to execute from “Project1” directory if possible so I don’t have to change the file location everytime.

  • 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-25T16:47:04+00:00Added an answer on May 25, 2026 at 4:47 pm

    You can use one of ClassLoader class methods

    public URL getResource(String name)
    or 
    public InputStream getResourceAsStream(String name)
    

    to locate and access any resource in the classpath in a way that is independent of the location of the code. For exaple

    InputStream myTextFileStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("Project1/Hello.txt") ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at building a Rails application which will have some pretty large tables
I have a bunch of pretty large CSV (comma separated values) files and I
I'm going to start an pretty large project witch contains 30+ modules, I have
I have a large project which I am replacing 2 parts of with better
I have a pretty large project that just recently started crashing on exit. I
I have a pretty large site and every page is built from several included
I have an application that is pretty memory hungry. It holds a large amount
I have been handed a large Spring - Hibernate project and have been told
I have to develop a fairly large ASP.NET MVC project very quickly and I
I'm still a pretty new project, and I haven't really worked on any large

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.