0

I am setting up a project that requires several non java resource that will ship with the application, I have created a directory structure in my project root directory.

src/                           - Java packages and classes
resource/media/icons/          - Button, form and table icons
resource/media/images/         - Report and application images
resource/media/reports/        - Jasper report templates
resource/help/                 - Help documentation

I added the resource directory to the class path by adding it as a source folder, is this the correct way to do this?

When I export the project will the resource also export?

How should I should be accessing these files, what would the URL be to access the ShippintTimes report template in the resource/media/reports/ directory?

// Current example accessing a report
String reportUrl = "resource/media/reports/ShippintTimes.jasper"

Do I need to do anything to make the URL operation system independent?

Are there any conventions regarding where to place non java application resource?

I know there are several questions, any hints help or examples as to how I should be structuring my project reports will be much appreciated.

Levi Putna
  • 2,863
  • 6
  • 30
  • 47

1 Answers1

0

As long as your resource folder is in classpath you can refer to resources in your project by:

getClass().getResourceAsStream("path");

Note that the absolute path here starts without / and relative starts with /
See: File loading by getClass().getResource()

Nick
  • 744
  • 6
  • 11