JNI error occurred, check your installation and try again in Eclipse x86 Windows 8.1

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 fine on my laptop for a friend and throws this error on my laptop. I run the code on Eclipse Juno using Java 7. I also tested and ran a lot of java programs on my laptop, everything works fine. This is the only program that gives such an error. This is my last project, and I need it to work on my laptop, I will be grateful to everyone who helps.

+35
java eclipse mysql jni java-native-interface
source share
33 answers
  • one
  • 2

Short answer: Right-click the class that contains the main method. Click Run As. Click on the Java Application. Keyboard shortcut: Shift + Alt + XJ (hold Shift and Alt, press X; then release Shift and Alt and press J).

Long answer: To be honest, I'm not 100% sure why this problem occurs. This may be due to using a different JDK. I encountered the same error. The solution was simpler than I expected. I'm used to running my code with Ctrl + F11. But when I launched it as a Java application (as I described in the "short answer"), the problem was resolved. I'm not sure if this solves other people's problems, but worth a try. :)

+29
source share

Error: A JNI error has occurred, check your installation and try again in Eclipse

Solution: Check your package name as it may interfere with the package name in java. Just change the package name to solve the problem. :)

+9
source share

I had similar problems when using "java" at the beginning of the package name, for example. java.jem.pc

Check the console output, I get: An exception in the stream "main" java.lang.SecurityException: Forbidden package name: java.jem.pc

+8
source share

In my case, the problem was caused by the JDK version . To solve this problem, I suggest <jdk.version>1.7</jdk.version>. to your pom file and checking out <jdk.version>1.7</jdk.version>.

Then check the java version in your cmd (windows) or terminal (OSX or LINUX) by typing: java -version .

Compare the version shown on the terminal \ command line with what you have in your pom file. Make sure they are the same. Then run the project again.

+4
source share

Starting the jar from the command line:

 C:\folder\where\jar\stored>java -jar JarName.jar 

I got information that clarified the problem:

main / Main was compiled by a later version of Java

enter image description here

In this case, jar was compiled with a version newer than jre supports.

+4
source share

I also ran into the same problem. By looking at the console talking

Java.lang.SecurityException problem.

Decision:

Check the name of your project.

Hope your problem is resolved. If not, please print a console trace to track the root cause.

+3
source share

This can happen if the JDK version is different.

try this with maven:

 <properties> <jdk.version>1.8</jdk.version> </properties> 

in build-> plugins:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> </plugin> 
+3
source share

You can check the console first to see the actual error message, and then continue to search for answers to this error.

My console shows a NoClassDefFound error for the jcommander class. Your error will probably be different from mine. The reason for my error is that the jcommander class is not in my M2 repository, so I just need to add this dependency to my pom.xml. You can check if all dependent classes are declared and added to the current configuration and project configuration.

NoClassDefFoundError

+2
source share

Hi, I ran into a similar issue in a project in IntelliJ with Maven dependencies.

I decided by changing the scope of the dependencies on the provided compilation.

IntelliJ :

File> Project Structure> Modules> Dependencies> Scope (provide for compilation)

+2
source share

I found that adding these lines of code to the maven project's pom.xml file solves similar problems for me:

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.packagename.MainClassName</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> <configuration> <createDependencyReducedPom>false</createDependencyReducedPom> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 
+2
source share

I had this problem for a while, but now I figured it out.

It turns out that Java JDK 12 has both a JRE and a JDK inside the bin folder of the Java 12 JDK. (I always thought that JRE and JDK are different applications, but it turns out that everything has changed)

My problem was that Java JDK 12 was installed on my computer

At the same time, Java 8 (JRE) was installed on my computer.

So my computer is confused.

With my setup of the command line environment to run Java and Javac commands:

I typed the following commands:

 java -version 

// it gave me Java 8

After that I typed:

 javac -version 

// this gave me Java 12

In other words, my program compiles with Java 12, and I'm trying to work with Java 8.

To solve this problem, I uninstalled the Java 8 JRE from my computer.

Returned to the command line to check if "java -version" and "javac -version" return the same version number, and yes, it returns Java 12.

I tried to recompile my program again and run it. It worked !!

It worked! Eureka !!

+2
source share

Check out the console. It talks about java.lang.SecurityException error. Change your package name. I changed the package name from "java.assessment" to "assesment" and this worked for me. If anyone knows the root cause, please let me know.

+1
source share

POSSIBLE SOLUTION If NONE of these solutions worked for you, try this ... I finally got my job by deleting the two folders ".metadata" and ".recommenders" in the workspace folder. You can find the path to the workspace folder by clicking File> Switch Workspace> Other in the toolbar of the Eclipse application.

Now I am a complete noob crying my way through an SE degree at San Jose State University. So I'm just sharing what worked for me, not knowing why. I do not know what harm or headaches, or even if both of the above folders need to be deleted. But in the end, it worked for me, and it seems like the application is just updating new versions of these folders anyway.

+1
source share

I ran into a similar problem and got a solution in the package name. I saved the package name as java.basics. In the console, I received a hint of this, as it is clearly stated that the name of the forbidden package. So I changed the package name and it worked.

0
source share

edit the ".classpath" and include the tag below

<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>

This may solve your problem.

0
source share

Hope this helps someone else. I suffered from this while working on a project several years ago, and then work on a new project started unsuccessfully a few days ago. I found this post and tried to remember what I changed in my project, and then I remembered that I changed my maven pom and deleted the entry for maven-jar-plugin. When you create a jar whose purpose is to be executable, you need to enable it so that some entries are written to the manifest. I opened an old project, copied this entry (with some changes to the project name), and it worked.

0
source share

I think this is because the name of your class is the same as the name of another class in the JDK. Help the eclipse determine which one you are trying to run by selecting the package in which your class is located. Go to complete the configuration , select the project and the main class .

When you press the search button to select the main class, you will find the parameters with the same name , but with a different package , select your class.

0
source share

My problem arose from trying to disable the nature of Maven in my project and then delete the pom.xml file. This is bad, very bad, do not do this. If you do, change it back to the Maven project and hopefully you can restore the old pom.xml file or create a new one. As soon as I did this, it worked again.

EDIT: I recently ran into this problem again, and this time it was because I had duplicate libraries in my classpath. The one that Maven added (which started with / M2_REPO / .... and then the one I added (which I shouldn't have done). Despite the fact that Eclipse reported that it could not find the class, the real problem was in that I had given him two libraries with the same class, and he did not know which one to use. As soon as I deleted the second link, it worked.

0
source share

There was no information in my console, so I submitted a search for additional solutions and found them to be unique to the solutions presented here. I came across this when Eclipse Oxygen tried to run the old Ant build for the project.

Reason 1 I configured Eclipse to use an external Ant installation that was version 1.10.2, which apparently had classes compiled with JDK 9. In Eclipse, I got the JNI error described above (running Ant build from the command line gave I have known the error "unsupported version of major.minor" - Java, which I used on the system, was JDK 8).

The solution was to roll back to the built-in version of Ant Eclipse 1.10.1. I checked this as the right solution, downloading Ant 1.10.1 separately and reconfiguring Eclipse to use the new 1.10.1 externally, and it still worked.

Reason 2 This can also happen if you have improperly configured Ant runtime settings in the Eclipse settings. Depending on the version of Ant you are working with, you need to add tools.jar from the corresponding JDK to the class path used for the Ant runtime (Home Entries). More specifically, without proper configuration, Eclipse will complain when running the Ant target that the JRE version is smaller than the specific version required.

Essentially, “proper configuration” means aligning each of the configuration items in Eclipse to run Ant so that they all work together. This includes the entry Ant Runtime Home (should indicate an Ant version compatible with the JDK of your choice - you cannot run Ant with JDK 8 when it was compiled with JDK 9); specifying tools.jar which belongs to the JDK with which you want to run Ant in the Ant Runtime settings; and finally, setting up the JRE environment of your build script on the JDK with which you want to run Ant in the configuration of external tools. All 3 of these settings must be consistent to avoid the error described above. You will also need to consider the attributes used in your javac tag to make sure that the JDK you are using is capable of executing according to your instructions (i.e. JDK 7 cannot compile code using source and target version 8).

Moreover, if you are really trying to run the Ant build script to compile the code into an older JDK (for example, less than 8 for Oxygen), this article helped you get access to running Ant against the older JDK . There are Ant plugin replacements for several versions of Eclipse, the instructions are brief, and it is important to get the correct plugin version for your particular Eclipse.

Or, simply put, you can use this very good solution for your legacy compilation, which does not require replacing your Eclipse plugin, but instead modifies the javac tag in your build script (when using the latest version of the JDK).

0
source share

I encountered the same error when I added the following maven dependency to my project:

 <artifactId>aws-encryption-sdk-java</artifactId> 

The error only occurred when I ran the shadow jar file created by maven-shade-plugin . I was able to overcome the error using the jar created by maven-assembly-plugin .

0
source share

Not everything works for me, but as soon as I delete ".metadata" and ".recommenders" from the workspace, and also delete the folders "bin" and "setting", and then after re-importing the same project, this works for me.

0
source share

Faced the same problem in Netbeans 8.0.2. Clean and Build Project solved this problem.

0
source share

You can try: right-click on the project, and then click the clear button. Then run the project.

I like.

0
source share

Programs written for one version of jdk will not support the JNI platform of another version of jdk. If in this case we use jdk10 and jdk8, eclipse is configured for jdk10 and the code is written in jdk10. Now I don't want to use jdk10 and started using jdk8 as jvm and tried to run code that is written in jdk10, so the eclipse will happen due to a JNI error. So, to get out of this error, please add the current JVM path to the eclipse.ini file, then copy the recorded code to the clipboard and delete the project in eclipse, create a new project, check the copied code and run it.

0
source share

If the problem occurs during the installation of ANT, check your ANT HOME: it should point to the same folder in which you work.

This happened to me when I reinstalled the new version of eclipse and uninstalled the previouis eclipse fodler, preserving the previous ant: ant file, I just could not find any java library.

This in this case, the reason is not a bad version of the JDK.

0
source share

I have the same problem. Can anyone suggest a solution for this ..?

enter image description here

0
source share

I faced the same problem due to the fact that the packaged name was "Java", after renaming the package name there is no error.

0
source share

I had the same problem, however in my case it was related to the configuration settings in IntelliJ IDEA.

Although the project SDK (File → Project Structure) was installed on Java 11, the JRE in the Run / Debug Configuration (Run → Edit Configurations) was installed on Java 8. After changing this on Java 11, it worked like a charm.

0
source share

In my case, Eclipse was giving me this error, but I was getting a classnotfoundexception exception for javax.servlet.http.HttpServlet in the logs.

In my case, I tried to run the spring boot application with exclude module: 'spring-boot-starter-tomcat' in my build.gradle (since I am deploying on Wildfly).

The decision was to comment on this rule. JNI eclipse error is very misleading, and I would suggest fixing it.

0
source share

had the same problem. I imported a newer version of the json library (deleted the old one, but did not remove it from the build path). Solved this by removing the link to the old one from the build path

0
source share
  • one
  • 2

All Articles