Why can't I run my .jar file normally? (MacOS)

Viewed 32

I just programmed my first JFrame and exported it, but I'm not able to run the .jar file normally. When I try to run it using Terminal, it works without any problems. However, when I try to open the file normally by double clicking on it, I get an error message similar to this: The Java jar file "Programm.jar" could not be launched. Here's the code (maybe there's something wrong with it?):

package GUI;

import javax.swing.JFrame;

public class Frame {
    
    public static void main(String[] args) {
        
        JFrame jf = new JFrame();
        jf.setVisible(true); 
        jf.setSize(500, 300);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setLocationRelativeTo(null);
        jf.setTitle("Programm");
        jf.setResizable(false);
        
            
    }

}

Thanks in advance!

1 Answers

I think you need to associate the file type with the java executable, then the Finder will know what to do when you double click

Related