javaeclipsejavax.sound.midi

Eclipse can't resolve MidiSystem.getSequencer()


Eclipse is throwing the error :

"MidiSystem.getSequencer cannot be resolved to a type"

I am running JavaSE- 1.7 with compliance level 1.7

Not sure what is going on here

import javax.sound.midi.*;
public class drumKit{

    public void play(){
        try{
            Sequencer sequencer = new MidiSystem.getSequencer();
            System.out.println("got it");
        }
        catch(MidiUnavailableException ex){
            System.out.println("Cannot find");
        }
   }

    public static void main(String[] args){
        drumKit d = new drumKit();
        d.play();
   }
}

Solution

  • getSequencer() is a static method , no need to use the new keyword

    public void play(){
        try{
            Sequencer sequencer = MidiSystem.getSequencer();
            System.out.println("got it");
        }