I have made a JFrame application in which i have made a method and added a button with button click event.Now i have called this method from button click as well as from main method .As per my need i need to run this application as jar file..If jar file has been run it should execute the method directly and if button is clicked it should again invoke the same...

Now the problem is this that while executing it on Netbeans IDE its working file but while executing it from jar file it is giving error..

Here is My code..

Method:

       public static void captureCDRProcess(){}

Button click event.

 button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {

            captureCDRProcess();

        }
    });

and here is my main method:

 public static void main(String args[]) {

    captureCDRProcess(); 

    JframeGuiProcessingCDRcallCost frame = new JframeGuiProcessingCDRcallCost() {
        @Override
        public void actionPerformed(ActionEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };


    frame.setTitle("Process Cdr");
    frame.setSize(600, 400);
    frame.setLocation(200, 100);
    frame.getContentPane().setBackground(Color.cyan);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.setVisible(true);

}
有帮助吗?

解决方案

If you want to run jar you should add manifest file to your jar. You can find more at: http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top