Exporting jars with resources

前端 未结 3 1700
逝去的感伤
逝去的感伤 2021-01-14 19:43

I\'m trying to build a large Java project by building many small, modular projects. I want each small project to be entirely self contained, holding all of its resources (su

3条回答
  •  无人及你
    2021-01-14 20:07

    To add another source folder for your resources first create the folder. In a java perspective, select the project and from the context menu choose "configure build path". In the source folder tab you can make that newly created folder a source folder for your project. From then on, all resources under that folder can be exported to a jar with the project classes.

    By the way, the path you specify for getResourceAsStream is either just the resource file name if the resource is in the same package as the class or is the relative path name (starting with a slash) for the resource from the source folder you're using.

提交回复
热议问题