user1605892
user1605892

Reputation: 127

Where to put sound files in java project?

I am adding sounds to my java project that I am making with NetBeans. Where is the best place to put the sound file? In the package? The source folder? Libraries? Make a new folder? Where is the best place to put it?

Upvotes: 3

Views: 1484

Answers (1)

David Kroukamp
David Kroukamp

Reputation: 36423

Depending, if your app is made to be portable - as in just a single jar file - which can be executed without the need of worrying about where resources are located, I'd suggest packaging all resources in your jar file in a separate package and then accessing them using getResourceAsStream. See my answer here for extracting resources not contained in your main package: Exporting jars with resources. This also helps end users to not accidentally delete a resource or resources' folder.

However, if your application is installed on the user machine i.e Program Files, then it would be fine to keep it in a separate folder inside your apps folder as the user is not moving your app from PC to PC and thus wont forget to copy any resources.

Upvotes: 2

Related Questions