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()); } }
The above code works perfectly on my friend's laptop and throws this error on my laptop. I have running the code on Eclipse Juno using Java 7. I have also tested and run a lot java programs on my laptop all works well. This is the only program which gives such an error. This is my final year project and I need it to work on my laptop, I will be greatful to anyone who helps
JNI Error in Windows CMD jar or if you have compiled your program with Eclipse before. To fix the error, you need to adjust the environment variables for Java. To do this, type “environment variable” in your Windows search and open the “Edit System Environment Variables” item.
The most common cause of the JNI error while trying to set up a Minecraft server is due to the Java version installed on the machine being outdated. Fortunately, it's easy enough to fix this issue via simply updating Java.
This a JNI error has occurred Minecraft server error occurs when you try to start Minecraft or a Minecraft server on a PC that does not have the latest version installed. To fix this, you just need to update your current Java to the latest version.
I have been having this problem for a while, but now I have figured it out.
It turns out that Java JDK 12 have both the JRE and the JDK inside the bin folder of the Java 12 JDK. (I have always believed that JRE and JDK are different application, but it turns out things have changed)
My problem was that I had Java JDK 12 installed on my computer
At the same time, I had Java 8 (JRE) Installed on my computer.
So my computer is getting confused.
With my command prompt environment setup to run Java and Javac commands:
I typed the follow commands:
java -version
// this gave me Java 8
After that, I typed:
javac -version
// this gave me Java 12
In other words, my program is getting compiled with Java 12 and I am trying to run with Java 8.
To solve the problem, I uninstalled Java 8 JRE from my computer.
Went back to command prompt to check if "java -version" and "javac -version" is returning the same version number, and yes, it is returning Java 12.
Tried recompiling my program again, and running it. It Worked!!
It worked! Eureka!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With