问题
I am making a game using a client-server model. Currently I have 3 projects: client, server, and common. Currently all of the resources for the game are in a folder inside the common project, which is recognised as a source folder by Eclipse.
This allows me to access the resources from within the client and server projects using:
InputStream in = SomeClass.class.getClassLoader().getResourceAsStream(filename);
The problem is that this method only works for reading the files, but I want to be able to write to these files, too (e.g. saving a level in the level editor).
I'm imagining the built project looking something like this:
- Game/resources/...
- Game/client.jar
- Game/server.jar
Can anyone recommend a way that I can configure my project so that Eclipse will build it in this way, or in such a way that both the client and server will be able to access the shared resources?
来源:https://stackoverflow.com/questions/29703607/sharing-resources-between-java-projects-in-eclipse