Eclipse: share code among multiple projects

后端 未结 2 1317
失恋的感觉
失恋的感觉 2021-01-02 03:36

I have different projects in Eclipse (java me midlets) which all need to share code. Currently I duplicate things, but this is not ideal. What is the best way to do this? Th

相关标签:
2条回答
  • 2021-01-02 04:13

    You can create a Java Project which will contain the shared code and have other projects reference it. When deploying you can pack this project as a separate jar file.

    0 讨论(0)
  • 2021-01-02 04:16

    Have you considered creating a shared library instead of just shared code? Export to a JAR file and import that into the dependent products.

    The up-side of doing this (vs just referencing the shared code) is that it will force you into more rigorous practices. You will now have an API that must be maintained and versioned cleanly. It will also make you better consider what's shared and what's not. This will likely lead to better encapsulation, and hopefully better testing.

    I'm not saying you lack these things now. Just that creating a common-foo.jar can often encourage better habits.

    0 讨论(0)
提交回复
热议问题