gpt4 book ai didi

java - 错误 "A JNI error has occurred. Please check your installation and try again in Eclipse x86 Windows 8.1"

转载 作者:IT老高 更新时间:2023-10-28 21:00:12 24 4
gpt4 key购买 nike

考虑:

public class LoginCumReg implements ActionListener, KeyListener {

private JFrame form;
private JTextField txtunm;
private JTextField txtnm;
private JTextField txteml;
private JButton cmdcreate;
private JPasswordField txtpass;
private JPasswordField txtpassreg;
private JButton cmdok;
private JLabel lblunm;
private JLabel lblpass;
private JLabel lbleml;
private JLabel lblpassreg;
private JLabel lblnm;
private JPanel panel_1;

public LoginCumReg() {
// Construct components
form = new JFrame("Sign Up");
form.getContentPane().setFont(
new Font("Plantagenet Cherokee", Font.BOLD, 18));
txtunm = new JTextField(5);
txtunm.addKeyListener(this);
txtunm.setBounds(637, 55, 100, 25);
txtnm = new JTextField(5);
txtnm.setBounds(637, 228, 100, 25);
txteml = new JTextField(5);
txteml.setBounds(637, 264, 100, 25);
cmdcreate = new JButton("Create Account");
cmdcreate.setBounds(527, 350, 188, 25);
txtpass = new JPasswordField(5);
txtpass.setBounds(637, 91, 100, 25);
txtpassreg = new JPasswordField(5);
txtpassreg.setBounds(637, 300, 100, 25);
cmdok = new JButton("OK");
cmdok.setBounds(527, 139, 100, 25);
lblunm = new JLabel("UserName");
lblunm.setBounds(527, 55, 73, 25);
lblpass = new JLabel("Password");
lblpass.setBounds(527, 91, 100, 25);
lbleml = new JLabel("Email ID");
lbleml.setBounds(527, 264, 100, 25);
lblpassreg = new JLabel("Password");
lblpassreg.setBounds(527, 300, 100, 25);
lblnm = new JLabel("Full Name");
lblnm.setBounds(527, 228, 100, 25);

// form.setResizable(false);

// Adjust size and set layout
form.setPreferredSize(new Dimension(800, 450));

form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
form.getContentPane().setLayout(null);

// Add components
form.getContentPane().add(txtunm);
form.getContentPane().add(txtnm);
form.getContentPane().add(txteml);
form.getContentPane().add(cmdcreate);
form.getContentPane().add(txtpass);
form.getContentPane().add(txtpassreg);
form.getContentPane().add(cmdok);
form.getContentPane().add(lblunm);
form.getContentPane().add(lblpass);
form.getContentPane().add(lbleml);
form.getContentPane().add(lblpassreg);
form.getContentPane().add(lblnm);

cmdcreate.setActionCommand("Create Account");
cmdcreate.addActionListener(this);
cmdok.setActionCommand("Login");

JPanel panel = new JPanel();
panel.setBounds(502, 29, 254, 154);
panel.setFont(new Font("Palatino Linotype", Font.PLAIN, 14));
panel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,
null, null), "LOGIN", TitledBorder.LEADING, TitledBorder.TOP,
null, null));
panel.setBackground(SystemColor.controlHighlight);
form.getContentPane().add(panel);

panel_1 = new JPanel();
panel_1.setBounds(500, 204, 254, 186);
panel_1.setFont(new Font("Palatino Linotype", Font.PLAIN, 14));
panel_1.setBorder(new TitledBorder(new EtchedBorder(
EtchedBorder.RAISED, null, null), "SIGN UP",
TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel_1.setBackground(SystemColor.controlHighlight);
form.getContentPane().add(panel_1);

JLabel lblNewLabel = new JLabel("New label");
lblNewLabel.setBounds(91, 139, 286, 101);
lblNewLabel.setIcon(new ImageIcon(
"C:\\Users\\JAsh\\Desktop\\Projects\\JAsh.png"));
form.getContentPane().add(lblNewLabel);

JPanel panel_2 = new JPanel();
panel_2.setBounds(77, 118, 315, 145);
panel_2.setBorder(new EtchedBorder(EtchedBorder.RAISED,
SystemColor.activeCaptionBorder, SystemColor.menu));
panel_2.setBackground(SystemColor.controlHighlight);
form.getContentPane().add(panel_2);
cmdok.addActionListener(this);

form.setResizable(false);
form.pack();
form.setVisible(true);
System.out.println("const..");
}

public static void main(String[] args) {
new LoginCumReg();
}

@Override
public void actionPerformed(ActionEvent ae) {
// TODO Auto-generated method stub

if (ae.getActionCommand().equals("Create Account")) {
new Registration(txtnm.getText(), txteml.getText(), new String(
txtpassreg.getPassword()));
form.setVisible(false);
}

if (ae.getActionCommand().equals("Login")) {
try {
if (txtunm.getText().equalsIgnoreCase("admin")
&& new String(txtpass.getPassword()).equals("admin")) {
form.setVisible(false);
new Admin();
} else {
DataBase db = new DataBase();
db.connect();
String sql = "SELECT * FROM LOGIN WHERE USERNAME='"
+ txtunm.getText() + "'";
ResultSet rs = db.getDDL(sql);
boolean found = false;
while (rs.next()) {
if (rs.getString("Password").equals(
new String(txtpass.getPassword()))) {
found = true;
form.setVisible(false);
String name = rs.getString("FullName");
Session.startSession(txtunm.getText(), name);
new FacultyWelcome();
}
}
if (!found)
JOptionPane.showMessageDialog(new JFrame(),
"Invalid Credentials");
db.close();
}
}
catch (Exception e) {
}
}
}

@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}

@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}

@Override
public void keyTyped(KeyEvent arg0) {

// TODO Auto-generated method stub
// JOptionPane.showMessageDialog(new JFrame(), arg0.getKeyChar() + "-" + arg0.getKeyCode());
}
}

上面的代码在我 friend 的笔记本电脑上完美运行,并在我的笔记本电脑上抛出了这个错误。我已在 Eclipse v4.2 上运行代码(Juno) 使用 Java 7。

我还在我的笔记本电脑上测试并运行了许多 Java 程序,它们都运行良好。这是唯一出现此类错误的程序。

我该如何解决这个问题?

最佳答案

这个问题我已经有一段时间了,但现在我想通了。

事实证明,Java JDK 12 在 Java 12 JDK 的 bin 文件夹中同时具有 JRE 和 JDK。 (我一直认为 JRE 和 JDK 是不同的应用程序,但事实证明事情已经改变了。)

我的问题是我的计算机上安装了 Java JDK 12。同时,我的计算机上安装了 Java 8 (JRE)。所以我的电脑开始糊涂了。

将我的命令提示符环境设置为运行 Java 和 Javac 命令:

我输入了以下命令:

java -version

这给了我 Java 8。

然后,我输入:

javac -version

这给了我 Java 12。

换句话说,我的程序正在使用 Java 12 编译,而我正在尝试使用 Java 8 运行。

为了解决这个问题,我从我的计算机上卸载了 Java 8 JRE。

我返回命令提示符检查“java -version”和“javac -version”是否返回相同的版本号,是的,它返回的是 Java 12。

我尝试再次重新编译我的程序并运行它。成功了!!

关于java - 错误 "A JNI error has occurred. Please check your installation and try again in Eclipse x86 Windows 8.1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22381202/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com