Question

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);

}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top