由于我是java的新手,所以我无法弄清楚为什么会发生此错误以及如何解决该错误。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Code;
import javax.swing.JTable;
/**
*
* @author Regan
*/
public class Report extends javax.swing.JFrame {
/**
* Creates new form Report
*/
public Report() {
initComponents();
for(int i=0;i<Auditor.report.size();i++)
System.out.println(Auditor.report.get(i));
String column[]={"Fragment ID","Status"};
String[][] data=new String[Auditor.report.size()+1][2];
data[0][0]="Fragment ID";
data[0][1]="Status";
for(int i=0;i<Auditor.report.size();i++)
for(int j=0;j<Auditor.report.get(i).size();j++)
data[i+1][j]=Auditor.report.get(i).get(j);
JTable jt=new JTable(data,column);
jt.setBounds(30,40,200,300);
jPanel1.add(jt);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setFont(new java.awt.Font("Lucida Bright", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(169, 11, 63));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("AUDITING REPORT");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 500, 50));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 470, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 390, Short.MAX_VALUE)
);
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 470, 390));
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Report().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables
}
上面的代码导致了错误,但是我仍然对它是IDE错误还是我的代码错误感到困惑。Visual Studio代码和NetBeans均会发生此错误
java.lang.Error: Unresolved compilation problem
?追溯:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
org.netbeans cannot be resolved to a type
org.netbeans cannot be resolved to a type
org.netbeans cannot be resolved to a type
at Code.Report.initComponents(Report.java:48)
at Code.Report.<init>(Report.java:20)
at Code.Report$1.run(Report.java:102)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
任何帮助都是要感恩的
java.lang.Error: Unresolved compilation error
问题的可能原因是什么?
这意味着您的源代码中某处存在编译错误,并且您尝试运行该代码而未解决编译错误。
异常中的错误消息表示类中存在错误Code.Report
。显然,代码尝试使用org.netbeans
软件包中的某些内容,但是编译器不知道该软件包是什么。我希望根本原因是缺少编译时项目依赖项。
- IDE是否是唯一的问题?
并不是的。可能的根本原因是您的项目配置不正确,并且您已经忽略了IDE在先前构建项目时向您显示的编译错误。
您的问题中没有足够的上下文来说明实际错误在哪里。但是您应该能够通过清洁和构建软件包并查看其报告的编译错误来找到它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句