facebook

Cannot run main application class after Maven Clean

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #610544 Reply

    Mork
    Participant

    I noticed today that in a maven project that when I do a “clean”, I can no longer run the main app class in MyEclipse. MyEclipse reports that it cannot load or run the application class.

    If I quit MyEclipse and restart, then the main application class runs again with the “>” button.

    Is this a bug in MyEclipse?

    Frustrating.

    As a test, I ran the exact same project (using separate project files but same maven project) in Intellij IDEA and had no problems. That is, I could to a maven clean and then run the main application class right away with no errors.

    Thanks

    • This topic was modified 5 years ago by Mork.
    • This topic was modified 5 years ago by Mork.
    • This topic was modified 5 years ago by Mork.
    #610561 Reply

    Brian Fernandes
    Moderator

    Mork,

    What I believe is happening is that when you run a mvn:clean, the compiled classes are being deleted, as they should. When you now run the program with the play button, there are no compiled classes to execute. However, MyEclipse goes into a compilation cycle when you restart, making the classes available for execution again. In IntelliJ, this recompilation is probably automatic after clean.

    What you can do is simply force a build after clean by using the Project menu, or refreshing the project in the workspace. If you’re running the clean via an Eclipse configuration, in the Refresh tab, choose, refresh resources upon completion, and project containing selected resource (see screenshots). In my tests this change ensured a build was automatically executed after the clean.

    Hope this helps!

    Attachments:
    You must be logged in to view attached files.
    #610567 Reply

    Mork
    Participant

    Thanks for your reply.

    I set up the Maven configuration per your screenshots (thanks for those screenshots, by the way), but got the same exact error after a clean:

    Error: Could not find or load main class app

    Restarting is still the only working solution after a clean to avoid that problem above.

    Thanks,

    • This reply was modified 5 years ago by Mork.
    #610616 Reply

    Brian Fernandes
    Moderator

    Mork,

    Okay, let’s try to figure this out – here are some additional steps to try.

    1) Manually refresh the project after build, just in case the launch configuration option did not kick in.
    2) Just as a test, make a change in one of your sources and save it, does this trigger the recompilation?

    If none of these help, clear your log, then run the clean, and send us the log file at this point, maybe something is preventing the recompilation here.

    Another possibility is having different build paths specified in your pom.xml and your Eclipse project properties. If you go to Properties > Java Build Path and check the Source tab, can you examine the default output folder, or look at the output folders for each source folder if they’re different? Typically, output is sent to target/classes for Maven projects.

    Finally, look at the Launch configuration that you’re trying to run the program with – anything look amiss on the Dependencies tab?

    Bottom line, there’s no reason why this shouldn’t work, a restart should definitely not be required – just need to figure out why it’s not working for you.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Cannot run main application class after Maven Clean

You must be logged in to post in the forum log in