• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Head First Java chapter 11 MiniMiniMusicApp

 
Rob Gman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting a rather nasty error at runtime when trying to get this very simple sound player to work, I get the same error with the code I typed out and the pre-written code that comes with the book :-/ so i guess there is nothing wrong with the code? Here is it



and this is the runtime error

Exception in thread "main" java.lang.UnsatisfiedLinkError: init_
at gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.init_(libgcj.so.81)
at gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.<clinit>(libgcj.so.81)
at java.lang.Class.initializeClass(libgcj.so.81)
at java.lang.Class.newInstance(libgcj.so.81)
at gnu.classpath.ServiceProviderLoadingAction.run(libgcj.so.81)
at java.security.AccessController.doPrivileged(libgcj.so.81)
at gnu.classpath.ServiceFactory$ServiceIterator.loadNextServiceProvider(libgcj.so.81)
at gnu.classpath.ServiceFactory$ServiceIterator.<init>(libgcj.so.81)
at gnu.classpath.ServiceFactory.lookupProviders(libgcj.so.81)
at javax.sound.midi.MidiSystem.getMidiDeviceInfo(libgcj.so.81)
at javax.sound.midi.MidiSystem.getSequencer(libgcj.so.81)
at MiniMiniMusicApp.play(MiniMiniMusicApp.java:12)
at MiniMiniMusicApp.main(MiniMiniMusicApp.java:6)



if anyone can tell me what this means i'd be very grateful
 
Vijay Raj
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at java.lang.UnsatisfiedLinkError in API doc, it says

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native


Vijay.
 
roshni bhagat
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you written the same code as in book or added something...because i have run the same code and it runs very well
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite sure what the UnsatisfiedLinkError means, but it might be worthwhile reinstalling your JDK.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this seems to stem from a native method call, I'm also curious what operating system you're using.
 
Rob Gman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ubuntu.... perhaps I should have mentioned that at the start?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Gman:
Ubuntu.... perhaps I should have mentioned that at the start?

Interesting. I found that AlsaMidiDeviceProvider seems to be part of open source Java sound from Tritonus.org. You might try updating/reinstalling that, or perhaps find an alternative.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have had UnsatisfiedLinkErrors on Ubuntu 5 before now, but not on Ubuntu 6.04 or 6.10. Might still be worthwhile trying to reinstall your JDK.
 
Arnout Engelen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran into the same. Looks like you have 'tritonus' installed (which should give you access to ALSA MIDI though the Java Sound API), but the native library wasn't loaded.

You can load the native library with:



This gets rid of the linking error (but still doesn't quite seem work for me: the ALSA MIDI device shows up in qjackctl, but connecting it to kmidimon doesn't show any notes coming though).
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"raboof",

Please read your private messages regarding an important announcement.

Thank you,

Rob
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rob Gman" you have a similar private message; make sure to read it please.
 
Atlantis Lacy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know if this is resolved but I removed the chapter 11 statement at the top of the code just before the import.

Atlantis lacy
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "removed" do you mean the package statement? Since package names are used when invoking class files with the JVM, that might make a lot of difference. There are bits in the Java Tutorials about packages, here too, which are worth reading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic