java,类*是公共的,应在名为*.java中声明 public class *

问题描述:

import javax.sound.midi.*;

public class MiniMusicCmdLine{

public static void mian(String[] args){
    MiniMusicCmdLine mini=new MiniMusicCmdLine();
    if(args.length<2){
        System.out.println("Don't forget the instrument and note args");
    }else{
        int instrument=Integer.parseInt(args[0]);
        int note=Integer.parseInt(args[1]);
        mini.play(instrument,note);
    }
}

public void play(int instrument,int note){
    try{
        Sequencer player=MidiSystem.getSequencer();
        player.open();
        Sequence seq=new Sequence(Sequence.PPQ,4);
        Track track=seq.createTrack();

        MidiEvent event=null;

        ShortMessage first=new ShortMessage();
        first.setMessage(192,1,note,100);;
        MidiEvent changeInstrument=new MidiEvent(first,1);
        track.add(changeInstrument);

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

        ShortMessage b=new ShortMessage();
        first.setMessage(128,1,note,100);;
        MidiEvent noteOff=new MidiEvent(b,16);
        track.add(noteOff);
        player.setSequence(seq);
        player.start();

    }catch(Exception ex){ex.printStackTrace();}

}

}

看了网上的解答,觉得自己只有一个顶级的public类,文件名也没错误,不知道自己错在哪了?

main 写错了,,,,,,,,

第二个类应该是静态的,加static

报什么错大哥,,字太少