Sharing resources between Java projects in Eclipse

女生的网名这么多〃 提交于 2019-12-25 04:53:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!