I'm trying to play an audio file. In my IDE (intellij) that works completely fine, but when running in a JAR, I get the error java.io.FileNotFoundException: D:\soni801\Documents\Redsea Productions\The Great X Wars\alpha-0.0.7.1.jar\audio\click.au (The system cannot find the path specified)
The file's location inside the JAR is audio/click.au, and the JAR is located at D:\soni801\Documents\Redsea Productions\The Great X Wars\alpha-0.0.7.1.jar which afaik should make the absolute path D:\soni801\Documents\Redsea Productions\The Great X Wars\alpha-0.0.7.1.jar\audio\click.au, however the system can't find a file at this location? What's happening here?
This is the code in my AudioPlayer.java file:
AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath() /*+ "/res"*/ + filePath).getAbsoluteFile());
Clip clip = AudioSystem.getClip();
clip.open(inputStream);
Alternatively, you can find the entire file, as well as the rest of the project, on the GitHub repository
All help is appreciated.
I am aware that this might be a duplicate of other questions, but unfortunately other solutions didn't solve my problem
If the question is unclear, comment any improvements I could make, and I will edit the question