Issue
Since I'm new to java, I couldn't figure out why this error occurred and how to resolve it.
/*
* 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
}
The above code causing the error but I'm still confused at whether it's a IDE error or my code error. This error happens on both Visual Studio code and NetBeans
- What are the possible causes of a
java.lang.Error: Unresolved compilation problem
? - Whether IDE is the only problem?
Traceback:
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)
Any kind of help is to be thankful
Solution
- What are the possible causes of a
java.lang.Error: Unresolved compilation error
problem?
This means you have a compilation error in your source code somewhere, and you have tried run the code without fixing the compilation error(s).
The error message in the exception is saying that there is an error in Code.Report
class. Apparently, the code trying to use something in the org.netbeans
package, but the compiler doesn't know what that package is. I expect that the root cause is that a compile time project dependency is missing.
- Whether IDE is the only problem?
Not really. The probably root cause is that your project is not configured correctly, and YOU have ignored the compilation errors that the IDE indicated to you when you previously built the project.
- The former can arises in different IDEs. Unless you configure the project dependencies correctly, the IDE cannot provide the correct classpath to the compiler.
- That latter is your fault, not the IDE's fault. You shouldn't ignore compilation errors.
There is not enough context in your Question to say where the actual error is. But you should be able to locate it by doing a clean and build of the package and looking at the compilation errors that it reports.
Answered By - Stephen C
Answer Checked By - Willingham (JavaFixing Volunteer)