• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help getting started

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Awesome, thanks Abdulla. It works great!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic