0

I have to use this project configuration:

Project 1
+ src
+ Model
  + Datamodel.dtd
Project 2
+ src

Project 1 does some work with xml and should load the dtd from the folder "Model". I put this folder in the classpath of project 1. Project 1 is in the classpath of project 2. In project 2, I call a class from project 1 which try to load "Datamodel.dtd". However, the path of my ressources points to the basepath of project 1 and not to project 2. Therefore it throws a "FileNotFoundException".

Any Ideas how to solve that?

1 Answers1

0

Only exported classpath entries are visible in dependent projects:

  1. Select project 1
  2. Go to Project > Properties tab Order and Export
  3. Check the checkbox of the Model classpath entry
howlger
  • 31,050
  • 11
  • 59
  • 99
  • The_Model_ classpath is already exported. The path of the exception still points to the directory of project 2. Well, I guess I have to use a classloader to load this ressource, right? Is there a way to retrieve a path of this ressource for accessing it with the filesystem? –  May 24 '20 at 11:05
  • @MrPotato You didn't mentioned that it is already exported. Resources on the classpath have to be read as `InputStream` (e.g. via `MyClass.class.getResourceAsStream(fileName)`), not as `File`. Please show your code. – howlger May 24 '20 at 13:13
  • I didn't know the feature before. So there is the problem. I used `File` and tried to read it and not `InputStream` with the ClassLoader. Now, it works well. Thanks. –  May 24 '20 at 19:51