【问题标题】:Running jar file and Calling a method from main method in java运行jar文件并从java中的main方法调用方法
【发布时间】:2013-10-25 14:38:56
【问题描述】:

我已经制作了一个 JFrame 应用程序,其中我制作了一个方法并添加了一个带有按钮单击事件的按钮。现在我已经从按钮单击以及主方法调用了这个方法。根据我的需要,我需要运行它应用程序作为 jar 文件。如果 jar 文件已运行,则应直接执行该方法,如果单击按钮,则应再次调用相同的方法...

现在的问题是,在 Netbeans IDE 上执行它的工作文件时,但是从 jar 文件中执行它时,它给出了错误..

这是我的代码..

方法:

       public static void captureCDRProcess(){}

按钮点击事件。

 button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {

            captureCDRProcess();

        }
    });

这是我的主要方法:

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

}

【问题讨论】:

  • 错误是什么?请附上堆栈跟踪
  • 这个错误与throw new UnsupportedOperationException("Not supported yet.");有关吗?

标签: java swing jar jframe main


【解决方案1】:

如果你想运行 jar,你应该将清单文件添加到你的 jar 中。 您可以在以下位置找到更多信息:http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-21
    • 2012-09-28
    • 2014-08-25
    • 1970-01-01
    • 2010-10-27
    相关资源
    最近更新 更多