Eclipse Code Recommenders Cannot Download Its Model Repository Index

Like many Coffee programmers who get "Fault: Could not find or load main class Principal" while running the Java program in Eclipse, I was also getting the same problem recently. The "Error: Could not find or load main grade" was rendered me puzzled fifty-fifty after my ten+ years of feel with Java errors and exceptions. Whenever I run my Java application either by Run configurations or right-click and run as a Java plan, I go an annoying popup complaining about "could not find or load the main class, the program will exit".

I further checked, the project was compiling fine, I can see the .course file for the primary class in the bin directory of Eclipse, and I can even meet the projection and output folder added on the classpath of Run configuration, but still, I am getting the "could not find chief class, the plan volition exit error".

I spent good two hours trying everything I could, calling teammates for aid (getting an extra pair of optics always helps in this kind of state of affairs),   searching on the internet, and lots of trial and error, just the mistake was persistent.

The get-go clue I got when I debug my Java program. I debug the Java application in Eclipse by right click and cull "Debug As Coffee program" and establish that information technology was throwing ClassNotFoundEexception for a third-party form.

It was a kind of breakthrough after wasting such a long time but still, the clue wasn't enough because the course belongs to one of the dependent JAR which was available in classpath just somehow Eclipse was not seeing it.

My fault was resolved subsequently deleting the existing run configuration where the User entry was not pointing to the default classpath. Simply deleting the run configuration and re-creating it by running the form past right click, "Run As Java program" will fix the error.

Solution of Error: Could not discover or load main class in Eclipse

Even though I managed to solve the problem just it was also much trouble for me and taken a lot of time. I don't want to face the same situation again, peculiarly if I am urgent to run my Java program to debug an urgent production effect. Hence, I have decided to jot down my feel with a couple of more tricks from the past. In this article, I'll share iii useful tips to solve the "could non observe or load main class mistake" in Eclipse.

1. Delete existing run configurations

When yous run the master class as "Run as Java Plan", it adds the default classpath of the project equally User entries into Run Configurations's classpath as shown below.

"Error: Could not find or load main class Main"  solution in Eclipse

The problem in my case was that my project also needed native libraries and due to other errors, I have been lilliputian with classpath. It seems while creating the run configuration past copying from another project, I deleted the old project with the default classpath and added a new project without the default classpath.

This acquired the problem as Eclipse was not detecting any dependent JAR in the projection. The problem was obscured by the error considering it always complains about the main class not found, similar to the annoying popup below:

How to fix main class not found error in Eclipse

Remember, if your primary class is dependent upon any other class or JAR file and if you believe everything in the classpath, then just delete the Run configurations and Run the main class as a Java program and then edit the run configuration. This solved the trouble in my example. You tin can further check out these free Java Programming Courses to acquire more than virtually classpath and how JVM search and load class files.

Also, some of you lot might not be getting this popup considering I got the popup only on Eclipse Kepler only when I tried to reproduce the issue in "Eclipse IDE for Coffee developers" on Eclipse Luna, I but got the "Error: Could non find or load main class Primary" in cherry and bold.

2. Check for missing library

If y'all run into a red assertion mark in your projection means some of the libraries which are added in the build path are either deleted or moved to some other location. Until you gear up this outcome, your project will not compile and no class is created in the bin directory, hence when you run your Coffee program, Eclipse'due south classloader will not find the chief class and throw this error.

Here is how your project volition look like if any library from the build path is missing due to any reason e.1000. somebody copied to another directory or you close the project from which they were added.

Eclipse Error: Could not find or load main class solution

To  solve this problem just follow the below steps:

  • Go to configure build path
  • Check which JAR is missing
  • Remove them and add them to the new location.

Yous can further join these Eclipse online courses to acquire more almost setting and building Java projects in Eclipse.


iii. Debug the Java programme

This will tell yous exactly which form is missing in the class path. I mean if your primary class is referring to some other grade from a tertiary-political party library and that library is non in the classpath, Eclipse will throw the same "main course non found error". When you run the program in debug mode, you tin can encounter exactly which grade the program is not able to found.

Here is how the debug configuration looks like, you just need to click the debug to start debugging your program, the JVM volition first automatically if it'due south non able to discover the main class and print the actual class and error in the console.

How to solve main class not found error in Eclipse

There were a couple of more reasons for "Fault: Could not notice or load main class Main" in Eclipse. I'll slowly add those also. If you want to aid y'all can put your problem and solution related to Eclipse main class not found fault and I'll add together those reasons in the main posts. I intend to make this mail my get-to identify whenever I get the ClassNotFoundException or NoClassDefFoundError in Eclipse to avert wasting more time in the time to come.

Other Eclipse tutorials and tips for Java developers

  • How to connect Eclipse to the Oracle database? (see here)
  • How to brand an executable JAR file in Eclipse? (meet here)
  • How to increase the heap size of the Java program running in Eclipse? (meet here)
  • How to gear up Unsupported major.minor version 52.0 fault in Eclipse? (see here)
  • 3 Maven Eclipse tips for Coffee developers (see hither)
  • Top xxx Eclipse keyboard shortcuts  for Java programmers (see here)
  • How to setup remote debugging in Eclipse (come across here)
  • How to adhere source code for the JAR file in Eclipse for debugging? (see here)
  • How to fix maven dependency search not working in Eclipse? (solution)
  • iii Books to learn and master Eclipse IDE for Java programming (books)

DOWNLOAD HERE

Posted by: masonproorty.blogspot.com