What does this compile error mean and how can I resolve it? The compiler points the error at line 86
final PiFace piface = new PiFaceDevice(PiFace.DEFAULT_ADDRESS, Spi.CHANNEL_0); and tells me
unreported exception java.io.ioexception must be caught or declared to be thrown Is it something to do with it needing a try/catch? As that's the best answer I've found from my searches however I'm not really sure how to implement it i had a go at that and it just produced more errors (you can see it's commented out).
The complete code is below:
public class Relay1 extends javax.swing.JFrame { public Relay1() { initComponents(); } private void initComponents() { // stuff that doesn't matter... } //try{ final PiFace piface = new PiFaceDevice(PiFace.DEFAULT_ADDRESS, Spi.CHANNEL_0); //}catch(IOException e){ //System.out.println("Something went wrong..."); //} public static void main(String args[]) throws InterruptedException, IOException { 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(Relay1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Relay1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Relay1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Relay1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Relay1().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; // End of variables declaration//GEN-END:variables }
try-catchandthrows.