0

I'm working on a framework-type project in Eclipse, that has a res folder attached with, as you guessed Resources inside of it. At the moment, they are crucial text-files that are to be read.

I also have a main test rig that is apart of it's own Eclipse project, as I plan to expand it in the future. This test rig has included the framework project on it's Build Path, so I can access classes from the framework as they are added.

But this is where my problems lie: If I want to import a class, that works fine. If I want to access a file through an InputStream, or Reader, it breaks. I know this is because the files included from the secondary project aren't placed inside the test rigs bin folder, rather they reside in their own bin in the other project.

Is there a way I can get my main project to access resources from the other without having to do ../../ trickery in my file paths? I plan on making this a real thing and don't want file paths doing things like that.

  • Possible duplicate of [how to get URL using relative path](https://stackoverflow.com/questions/3665484/how-to-get-url-using-relative-path) – Aakash Verma Jul 05 '17 at 05:08

1 Answers1

0

In eclipse do this,

Build Path ---> Configure Path ----> Click Project Tab ---> Add the project.

Also, you can package the other project in a jar and import it as an external jar.

Aakash Verma
  • 3,705
  • 5
  • 29
  • 66
  • As said in the question I have already done this! I can import classes but I can't access direct files as resources with streams... As for packaging as a jar, I'm still developing it and therefore require it to be "open" in project format, not jar format. –  Jul 06 '17 at 02:43
  • It's not possible to use resource from somewhere outside the project when you are gonna shift or deploy it afterwards because if you go outside your project, or totally depends on the file system structure and then how you deploy and keep your projects, so it needs to be changed; it doesn't matter whether you are doing some trickery or not, either system or you will end up using URLs. – Aakash Verma Jul 06 '17 at 03:28