..............
Printable View
..............
You could try showing us lines 12 and 24 from your SoundEffect class and showing a content listing of your jar file to demonstrate that the sound resource you're attempting to open is there. 'jar tf yourJarFile.jar' at the command line would do the trick.
..............
Try printing out the values of soundFileName and the URL so you can verify that they have correct values.
..............
What about printing out the URLs also. Do it both ways. In the IDE and standalone in the jar.
If it works in Eclipse, then its probably a path problem.
..............
Your URLs are all to disk files not to the contents of the jar file.
Where was the program executed that produced what you posted in post#7?
In the IDE or from the jar in a test folder.
..............
Does It work in the IDE? Now do it from the jar in a test folder.
..............
Run it from the command prompt and copy the contents of the screen here.
java -jar <YOURJARFILENAME>.jar
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
..............
Just out of interest: I see backslashes in resource paths (because developer uses Windows?), does that work in Java?
What is the null that was printed out?
..............
Try using /
..............
What println printed it? Add an id string to ALL the println so you know which one is printing
...println("This is me printing theVar=" + theVariableHere);
..............
That looks like it is looking in the jar file.Quote:
jar:file:/C:/Users/*****/Desktop/Test.jar!/sounds/break.wav
soundFileName println(): sounds/break.wav
What is ImageIO.read trying to do? What are its arguments? on line 19Quote:
java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1362)
at Fugel.load(Fugel.java:19)
..............
Change the code to use a URL object and print that out the same as for the sound files.The check that what is printed out is in the jar file with the correct path
..............
Why does the error keep moving around? What happened to The error in post#21
Please identify which classes are yours in the error message.
Look at the source lines referred to and see what variable is null. Then find out why it is null.Quote:
Exception in thread "main" java.lang.ExceptionInInitializerError
at Panel.load(Panel.java:37)
at Panel.<init>(Panel.java:31)
at Frame.<init>(Frame.java:23)
at Frame.main(Frame.java:33)
Caused by: java.lang.NullPointerException
at com.sun.media.sound.WaveFileReader.getAudioInputSt ream (WaveFileReader.java:180)
at javax.sound.sampled.AudioSystem.getAudioInputStrea m (AudioSystem.java:1128)
at SoundEffect.<init>(SoundEffect.java:26)
at SoundEffect.<clinit>(SoundEffect.java:12)