I have two classes (Play and editor). editor uses Play. Play uses some external files. I imported them into Eclipse in order to address them straight (as you can see on the first screenshot).

I want JAR to be able to contain these files withing and be able to work with (import) them. Is that possible? What options should I choose while exporting project to JAR?
I have two classes ( Play and editor ). editor uses Play . Play
Share
If you want to use the
.wavfiles from within a jar then instead of doingString path = System.getProperty("user.dir");and then loading the wav files from there, try doing something like :From here, it seems that
AudioSystemdoes have an overloadedgetAudioInputStreamwhich accepts anInputStreaminstead of aFileobject (as in your code). So you could have something like :For the above to work all your
*.wavfiles must be copied to a source folder so that they are present on the classpath. To do that you could move *.wav intosint/srcto start with (and then into a properwavfolder later on if needed). That would put them in the root of the classpath/and allow them to be referred to like so :/result.wav,/x_SECOND.wavetc.Working Code
Here is a bit of working code to test out
AudioInputStreamfrom here :The above code worked fine for me and I got two
truein the console.GIT Hub Repo with Test project
You should be able to import the project in this zip and see the code working.
Do you need a ‘Fat Jar’ ?
A bit off-topic, but if you need to build a
fat jarthat includes all the jars needed by your project to run and is a single executable then try using http://fjep.sourceforge.net/ plugin to build a fat jar.You can export a java project containing jars using the
File -> Export -> Other -> One Jar Exporter. The jar that’s thus built is an executable jar and needs nothing else to run.