package com.rupeng.test2; import javax.sound.midi.MidiEvent; import javax.sound.midi.MidiSystem; import javax.sound.midi.Sequence; import javax.sound.midi.Sequencer; import javax.sound.midi.ShortMessage; import javax.sound.midi.Track; public class MiniMusicApp { public static void main(String[] args) { MiniMusicApp mini = new MiniMusicApp(); mini.play(); } public void play() { try { // Get a sequencer and open it Sequencer player = MidiSystem.getSequencer(); player.open(); Sequence seq = new Sequence(Sequence.PPQ, 4); //Treat the arguments as Ready-bake arguments Track track = seq.createTrack(); // Ask the sequence for a track // Put some MidiEvents into the Track, the setMessage() method is what we should really care 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); // Give the sequence to the Sequencer // like pushing a CD to a CD player player.start(); // Start the sequencer like pushing PLAY } catch(Exception ex) { ex.printStackTrace(); } } // Close play }
2、eclipse导出jar包可执行文件
在eclpse中找到你要导出的java程序 选中它
3、在cmd中检测运行是否jar文件成功
4、在windows中加入定时任务
点击开始按钮,依次选择打开“所有程序—附件—系统工具”,找到“任务计划程序”即可打开Win7系统的任务计划设置面板。也可以点击Win7开始按钮,在多功能搜索框中输入“任务计划”,直接从搜索结果中打开。
创建基本任务
下一步