我是Java Applets的新手。我安装了JMStudio并在项目中添加了所有.jar文件,但仍无法正常工作。
我在项目中安装了.jar文件>属性> Java构建路径>库
这是我的计划:
import java.applet.*;
import java.awt.Button;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class design extends Applet implements ActionListener
{
Button play,stop;
AudioClip audioClip;
public void init(){
play = new Button(" Play in Loop ");
add(play);
play.addActionListener(this);
stop = new Button(" Stop ");
add(stop);
stop.addActionListener(this);
audioClip = getAudioClip(getCodeBase(), "About Time.mid");
}
@Override
public void actionPerformed(ActionEvent ae) {
Button source = (Button)ae.getSource();
if (source.getLabel() == " Play in Loop "){
audioClip.play();
}
else if(source.getLabel() == " Stop "){
audioClip.stop();
}
}
}
这是错误
java.lang.IllegalAccessError: tried to access class com.sun.media.sound.Printer from class com.sun.media.sound.HeadspaceSoundbank
at com.sun.media.sound.HeadspaceSoundbank.<init>(HeadspaceSoundbank.java:81)
at com.sun.media.sound.HsbParser.getSoundbank(HsbParser.java:69)
at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:535)
at com.sun.media.sound.SoftSynthesizer.getDefaultSoundbank(SoftSynthesizer.java:711)
at com.sun.media.sound.SoftSynthesizer.openStream(SoftSynthesizer.java:1150)
at com.sun.media.sound.SoftMidiAudioFileReader.getAudioInputStream(SoftMidiAudioFileReader.java:73)
at com.sun.media.sound.SoftMidiAudioFileReader.getAudioInputStream(SoftMidiAudioFileReader.java:145)
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1113)
at com.sun.media.sound.JavaSoundAudioClip.<init>(JavaSoundAudioClip.java:102)
at sun.applet.AppletAudioClip.createAppletAudioClip(AppletAudioClip.java:125)
at sun.applet.AppletAudioClip.<init>(AppletAudioClip.java:66)
at sun.applet.AppletViewer.getAudioClip(AppletViewer.java:383)
at java.applet.Applet.getAudioClip(Applet.java:329)
at java.applet.Applet.getAudioClip(Applet.java:349)
at com.design.init(design.java:20)
at sun.applet.AppletPanel.run(AppletPanel.java:434)
at java.lang.Thread.run(Thread.java:745)
我想问题可能出在JMF的安装上......但我不确切地知道我错在哪里。
请有人告诉在eclipse中运行JMF的确切方法。