3 ways to solve Eclipse - primary aeroplane non flora error

Like many Java programmers who gets "Error: Could non expose or charge principal course of educational activity Main" while running Java programme inwards Eclipse, I was also getting the same occupation recently. The "Error: Could non expose or charge principal class" was rendered me puzzled fifty-fifty afterward my 10+ years of sense alongside Java errors in addition to exceptions. Whenever I run my Java application either yesteryear Run configurations or correct click in addition to run every bit Java program, I acquire an annoying popup complaining close "could non expose or charge the principal class, the programme volition exit". I checked, the projection was compiling fine, I tin come across the .class file for the principal course of educational activity inwards the bin directory of Eclipse, in addition to I tin fifty-fifty come across the projection in addition to output folder added on the classpath of Run configuration, but all the same I am getting the "could non expose principal class, programme volition leave of absence error".

I spent skillful ii hours trying everything I could, calling teammates for assistance (getting an extra pair of oculus e'er helps inwards this sort of situation),  searching on the internet, in addition to lots of trial in addition to error, but the fault was persistent. The outset clue I got when I debug my Java program. I debug the Java application inwards Eclipse yesteryear correct click in addition to choosing "Debug As Java program" in addition to works life that it was throwing ClassNotFoundEexception for of a third-party class.

It was a sort of break-through afterward wasting such a long fourth dimension but all the same the clue wasn't plenty because the course of educational activity belongs to 1 of the theme JAR which was available inwards classpath but somehow Eclipse was non seeing it. My fault was resolved afterward deleting existing run configuration where User entry was non pointing to default classpath. Just deleting the run configuration in addition to re-creating it yesteryear running the course of educational activity yesteryear correct click, "Run As Java program" volition create the error.




Solution of Error: Could non expose or charge principal course of educational activity inwards Eclipse

Even though I managed to solve the occupation but it was besides much a problem for me in addition to taken a lot of time. I don't desire to expression upward the same province of affairs again, peculiarly if I am inwards urgency to run my Java programme to debug an urgent production issue. Hence, I conduct maintain decided to jot downward my sense alongside a distich of to a greater extent than tricks from the past. In this article, I'll portion 3 useful tips to solve "could non expose or charge principal course of educational activity error" inwards Eclipse. 


1) Delete the existing run configuration
When you lot run the principal course of educational activity every bit "Run every bit Java Program", it adds the default classpath of the projection every bit User entries into Run Configurations's classpath every bit shown below.

 I was also getting the same occupation lately 3 ways to solve Eclipse - principal course of educational activity non works life error


The occupation inwards my illustration was that my projection also needed native libraries in addition to due to other errors I conduct maintain been petty alongside classpath. It seems spell creating the run configuration yesteryear copying from about other project, I deleted the one-time projection alongside default classpath in addition to added novel projection without default classpath. This caused the occupation every bit Eclipse was non detecting whatever theme JAR inwards the project. The occupation was obscured yesteryear the fault because it e'er complains close principal course of educational activity non found, similar to the annoying popup below:

 I was also getting the same occupation lately 3 ways to solve Eclipse - principal course of educational activity non works life error


Remember, if your principal course of educational activity is theme upon whatever other course of educational activity or JAR file in addition to if you lot believe everything inwards the classpath, so but delete the Run configurations in addition to Run the principal course of educational activity every bit Java programme in addition to so edit the run configuration. This solved the occupation inwards my case. You tin farther read Core Java Volume 1 - Fundamentals to acquire to a greater extent than close classpath in addition to how JVM search in addition to charge course of educational activity files.

Also, about of you lot powerfulness non move getting this popup because I got the popup alone on Eclipse Kepler but when I tried to reproduce the lawsuit inwards "Eclipse IDE for Java developers" on Eclipse Luna, I but got the "Error: Could non expose or charge principal course of educational activity Main" inwards cherry-red in addition to bold.


2) Check for missing library
If you lot come across a red exclamation mark inwards your projection agency about of the libraries which are added inwards construct path is either deleted or moved to other location. Until you lot create this issue, your projection volition non compile in addition to no course of educational activity is created inwards the bin directory, thence when you lot run your Java program, Eclipse's classloader volition non expose the principal course of educational activity in addition to throw this error.

Here is how your projection volition hold back similar if whatever library from construct path is missing due to whatever argue e.g. mortal copied to about other directory or you lot closed the projection from which they were added.


 I was also getting the same occupation lately 3 ways to solve Eclipse - principal course of educational activity non works life error

To  solve this occupation but follow below steps:
  • Go to configure construct path
  • Check which JAR is missing
  • Remove them in addition to add together them from the novel location. 
You tin farther read Eclipse inwards Action: Influenza A virus subtype H5N1 Guide for the Java Developer to acquire to a greater extent than close setting in addition to edifice Java projects inwards Eclipse.



3) Debug the program
This volition nation you lot precisely which course of educational activity is missing inwards the classpath. I hateful if your principal course of educational activity is referring about other course of educational activity from a third-party library in addition to that library is non inwards the classpath, Eclipse volition throw the same "main course of educational activity non works life error". When you lot run the programme inwards debug mode, you lot tin come across precisely which course of educational activity the programme is non able to found.

Here is how the debug configuration hold back like, you lot but require to click the debug to start debugging your program, the JVM volition start automatically if it's non able to expose the principal course of educational activity in addition to impress the actual course of educational activity in addition to fault inwards console.

 I was also getting the same occupation lately 3 ways to solve Eclipse - principal course of educational activity non works life error


There were a distich of to a greater extent than reasons of "Error: Could non expose or charge principal course of educational activity Main" inwards Eclipse. I'll tardily add together those every bit well. If you lot desire to assistance you lot tin position your occupation in addition to solution related to Eclipse principal course of educational activity non works life fault in addition to I'll add together those reasons inwards the principal posts. I intend to brand this post my acquire to house whenever I acquire the ClassNotFoundException or NoClassDefFoundError inwards Eclipse to avoid wasting to a greater extent than fourth dimension inwards future.


Other Eclipse tutorials in addition to tips for Java developers
  • How to connect Eclipse to Oracle database? (see here)
  • How to brand executable JAR file inwards Eclipse? (see here)
  • How to increase heap size of Java programme running inwards Eclipse? (see here)
  • How to create Unsupported major.minor version 52.0 fault inwards Eclipse? (see here)
  • 3 Maven Eclipse tips for Java developers (see here)
  • Top xxx Eclipse keyboard shortcuts  for Java programmers (see here)
  • How to setup remote debugging inwards Eclipse (see here)
  • How to attach root code for JAR file inwards Eclipse for debugging? (see here)
  • How to create maven dependency search non working inwards Eclipse? (solution)
  • 3 Books to acquire in addition to original Eclipse IDE for Java programming (books)


Further Learning
The Eclipse Guided Tour - Part 1 in addition to 2
Java Web Fundamentals
The Java Developer's Guide to Eclipse

Subscribe to receive free email updates:

0 Response to "3 ways to solve Eclipse - primary aeroplane non flora error"

Posting Komentar