• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help getting started  RSS feed

 
V Jordan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I've installed and configured java 5 correctly, set the Path variable etc. I've tried running this app (my first app) from Kathy Sierra's book, but keep getting this error:

Exception in thread "main" java.lang.NoClassDefFoundError: MiniMiniMusicApp

The code is typed exactly as it appears in the book, here it is:

import javax.sound.midi.*;

public class MiniMiniMusicApp{
public static void main(String[] args){
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();
}

public void play(){

try{
Sequencer player = MidiSystem.getSequencer();
player.open();

Sequence seq = new Sequence(Sequence.PPQ, 4);

Track track = seq.createTrack();

ShortMessage a = new ShortMessage();
a.setMessage(144,1,44,100);
MidiEvent noteOn = new MidiEvent(a,1);
track.add(noteOn);

ShortMessage b = new ShortMessage();
b.setMessage(128, 1, 44, 100);
MidiEvent noteOff = new MidiEvent(b, 16);
track.add(noteOff);

player.setSequence(seq);

player.start();

} catch (Exception ex){
ex.printStackTrace();
}
}
}
 
V Jordan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awesome, thanks Abdulla. It works great!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What works great? Abdulla, nice of you to help, but if you helped by private message or email, then you're depriving other people of the benefit of your knowledge. Please, in the future, answer questions in the public forum whenever you can. Thanks.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch! I hope you keep coming back here with more questions. For future reference, I have some suggestions that will help us answer your questions more efficiently:

1) Describe how you run the program. For example, if you are running the program from the command line, you should give the exact command that you type. You should also include which directory you are in when you type the command.

2) Thanks for posting your code. It definitely helps so we can see what you are actually doing. You can make it a little more friendly by using UBB CODE tags around your code. This will preserve the formatting and make it much easier for us to read it.

If you follow these suggestions, we can probably answer your questions more quickly. A few extra minutes to provide these details will save you a lot of time in the long run.

Layne
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!