这个编译错误是什么意思,我该如何解决它?编译器将错误指向第86行。
并告诉我。
final PiFace piface = new PiFaceDevice(PiFace.DEFAULT_ADDRESS, Spi.CHANNEL_0);
并告诉我。
unreported exception java.io.ioexception must be caught or declared to be thrown
这是否与需要尝试/捕获有关?因为这是我在搜索中找到的最佳答案,但我不太确定如何实现它。我尝试了一下,但它只产生了更多的错误(你可以看到它被注释掉了)。
完整的代码如下:
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
}