[英]Running jar file and Calling a method from main method in java
我已經制作了一個JFrame應用程序,在其中我創建了一個方法並添加了帶有按鈕單擊事件的按鈕。現在我已經從按鈕單擊以及主要方法中調用了此方法。根據我的需要,我需要將此應用程序作為jar運行file ..如果已運行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);
}
如果要運行jar,則應將清單文件添加到jar中。 您可以在以下位置找到更多信息: http : //docs.oracle.com/javase/tutorial/deployment/jar/appman.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.