1
我正在为我的朋友做一个基本的程序,显示他的这个有趣的图片并循环播放声音。当我导出我的JAR它没有工作,所以我打开了JAR用WinRAR和文件都在那里,但他们并没有打如何将图像和声音导出到我的可运行jar包中?
CODE:
//imports
public class twerk {
static File fl = new File("res//sounds//liver.au");
static int loo = 1;
static JFrame frame = new JFrame("COLLIN");
public static void frame(){
frame.setSize(1086,800);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
ImageIcon image = new ImageIcon("res//images//collin.jpg");
JLabel label = new JLabel(image);
frame.add(label, BorderLayout.NORTH);
frame.setIconImage(image.getImage());
frame.setVisible(true);
try
{
String st =fl.getPath();
InputStream in = new FileInputStream(st);
AudioStream au = new AudioStream(in);
AudioPlayer.player.start(au);
if(loo == 1){
Thread.sleep(1900);
frame();
}
} catch(Exception e){}
}
public static void main(String[] args){
frame();
}
}
JAR文件的图片在WinRAR打开
所以你可以看到,图像和声音文件夹是jar文件,但他们没有被使用