Java executable .JAR file runs but doesn't open

Viewed 75

Hey guys I am new to programming and trying to make a java program in eclipse that has a laughing skull gif with a laughing sound. I'm trying to export it as a runnable .JAR file and it starts running but it never fully opens.

I have tried changing paths in windows, java is updated, i have run jarfix, i don't have malware on my computer, i have uninstalled and reinstalled java and eclipse. I don't know how to fix it and am in need of some help.

here is my code

import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.ImageIcon;
import java.io.File;
    
    public class Laughingskull extends JFrame
    {                   
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        /**
         * 
         */         
        public ImageIcon skull;
        public JLabel label;
        

        public static void main(String[] args) 
        {                                               
            JFrame jf = new JFrame();
            Laughingskull frame = new Laughingskull();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            jf.setLocationRelativeTo(null);     
            File Laugh = new File("evillaugh.WAV");
            PlaySound(Laugh);       
        }


        
        //customPanel   
    public Laughingskull() {        
        skull = new ImageIcon("fireskull.gif");
        label = new JLabel(skull);
        add(label); 
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        setUndecorated(true);
        setBackground(new Color(0,0,0,0));          
        }       


    
    static void PlaySound(File Sound) {
        try {
            Clip clip = AudioSystem.getClip();
            clip.open(AudioSystem.getAudioInputStream(Sound));
            clip.start();       
            Thread.sleep(clip.getMicrosecondLength()/1000);
            System.exit(0);
        }catch(Exception e) {                   
        }       
    }   
}
0 Answers
Related