Java Netbeans生成执行错误

Java Netbeans生成执行错误,java,exception,netbeans,build,Java,Exception,Netbeans,Build,我刚刚创建了一个Java应用程序,其中JFrame作为运行应用程序时打开的主窗口 我试图构建这个项目,但是当双击dist文件夹中的jar文件时,我得到一个错误,上面写着“发生了Java异常”,没有进一步的细节 有什么问题吗 谢谢 GUI表单代码: import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; public class Login extend

我刚刚创建了一个Java应用程序,其中JFrame作为运行应用程序时打开的主窗口

我试图构建这个项目,但是当双击dist文件夹中的jar文件时,我得到一个错误,上面写着“发生了Java异常”,没有进一步的细节

有什么问题吗

谢谢

GUI表单代码:

    import java.sql.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;

    public class Login extends javax.swing.JFrame {


    LoginClass lc;
    public Login() {
        this.lc = new LoginClass(this, UNField, PWField);        
       initComponents();
    }

    private void UNFieldActionPerformed(java.awt.event.ActionEvent evt) {                                        

    }                                       

    private void LoginBtnActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            lc.Login(UNField, PWField);
        } catch (SQLException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        }
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Login().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton LoginBtn;
    private javax.swing.JPasswordField PWField;
    private javax.swing.JLabel PWLabel;
    private javax.swing.JTextField UNField;
    private javax.swing.JLabel UNlabel;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration                   
}
登录类代码:

    import java.sql.*;
    import javax.swing.*;


    public class LoginClass {
        Login l;
        JTextField un;
        JPasswordField pw;
        ResultSet rs;
        PreparedStatement pst;
        Connection conn = DBConn.ConnectDB();

    public LoginClass(Login log, JTextField u, JPasswordField p){
        l=log;
        un = u;
        pw = p;
    }    

    public void Login(JTextField u, JPasswordField p) throws SQLException{
        try{
        String name = u.getText();
        String password = "" + p.getText();
        String sql = "Select * from tblUsers where userName = '" + name + "' and password = '" + password + "'";
        pst = conn.prepareStatement(sql);
        rs = pst.executeQuery();
        if(rs.next()){
            JOptionPane.showMessageDialog(null, "Credentials are correct.");
            Menu main = new Menu();
            l.setVisible(false);
            main.setVisible(true);

        }
        else{
            JOptionPane.showMessageDialog(null, "Invalid credentials entered.");

        }
        } catch(SQLException e){
           JOptionPane.showMessageDialog(null, e);
        }
    }
}

显示代码以获得更多帮助。@YeWin我添加了:)从命令行运行程序。我相信错误消息会更有意义。@jeanwaghetti程序从命令行正确运行。通过双击jar文件运行它,但仍然会出现相同的错误。请尝试下面列出的任何解决方案: