最近我做了一个 Netbeans 项目,并使用 SVN 来配合它。我看到重复的类错误,并在控制台中显示
java.lang.VerifyError: (class: pie/chart/explorer/PieChartExplorer, method: <init> signature: ()V) Constructor must call super() or this()
Could not find the main class: pie.chart.explorer.PieChartExplorer. Program will exit.
Exception in thread "main" Java Result: 1
这是 PieChartExplorer.java:
package pie.chart.explorer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class PieChartExplorer extends JFrame implements ActionListener {
JTextField one = new JTextField(10);
JTextField two = new JTextField(10);
JTextField three = new JTextField(10);
JButton sub = new JButton("Click to be amazed");
public PieChartExplorer() {
super("Pie Chart Explorer");
setSize(300,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout flo = new FlowLayout();
setLayout(flo);
setVisible(true);
add(one);
add(two);
add(three);
sub.addActionListener(this);;
add(sub);
}
public static void main(String[] args) {
PieChartExplorer app = new PieChartExplorer();
}
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if(source == sub) {
try {
Pie show = new Pie(Float.parseFloat(one.getText()),Float.parseFloat(two.getText()),Float.parseFloat(three.getText()));
} catch(Exception ex) {
JOptionPane.showMessageDialog(this, "Please check entered data");
}
}
}
}
我努力了:
- 清洁和重建项目
- 确保我在所有构造函数中调用了 super
如何解决这个问题?下载代码 http://www.mediafire.com/?kby3dfjqz99jui8.
我发现重命名包不起作用,旧包仍然存在。
当我将另一个应用程序中的包复制到当前应用程序中时,我的问题就开始了,当前应用程序已经有一个同名的包。我试图将一些缺失的类添加到包中。我这样做之后,错误开始了。
为了解决这个问题,我从目标 Web 应用程序中删除了整个包,并进行了清理和构建。然后我将源包复制到目标应用程序中。没有错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)