Solved InvalidPluginException: Cannot find main class error

Discussion in 'Spigot Plugin Help' started by Epicgame456789, Jul 19, 2021 at 1:21 AM.

  1. I'm working on a plugin for fun, when I needed to add Gson as a dependency in order to do some stuff. When I added it through modules -> dependencies, something happened (I have no idea what) and suddenly all of my java classes were "outside of source root". So after some research I decided to make a new source root, which was my src file. Everything seemed to be fine, except for one thing: my server couldn't find the main class, producing anInvalidPluginException error whenever I tried starting the server. I checked my plugin.yml file and as far as I know, I have the correct path for the main file. upload_2021-7-18_20-20-9.png
    These are the files: upload_2021-7-18_20-20-44.png
    And this is the error: upload_2021-7-18_20-21-7.png
    Anyone know what I can do to solve this?
    #1 Epicgame456789, Jul 19, 2021 at 1:21 AM
    Last edited: Jul 19, 2021 at 12:41 PM
  2. Open the jar with 7zip or winrar and follow the path to make sure that the class is there
  3. Use Eclipse if u r not good with IntelliJ
  4. You are not using gradle build.
  5. This isn't even an IntelliJ-related issue... it is a building issue... Please stop posting bad advice :D

    Also, if possible, could you provide more info. What are you doing to build? Can you show gradle settings/build info/etc. Whenever you unzip, does anything seem out of place?
  6. I mean for begginers it's better to use.
  7. This has nothing to do with this user’s issue. Stop posting, it’s never useful.
  8. Optic_Fusion1

    Resource Staff

    Is the plugin.yml file ANYWHERE in the compiled jar file?
  9. It is otherwise the plugin wouldnt say its not able to find the main class
  10. Optic_Fusion1

    Resource Staff

    Too late to do this shit xD

    OP has either the wrong class path or the main class just isn't in the jar
  11. in the picture it looks like the right path so i guess the jar isnt full lol
  12. Optic_Fusion1

    Resource Staff

    then they need to fix their shit.

    Use either maven or gradle if the IDE doesn't compile a FAT jar by default
  13. Seems like op is already using gradle maybe the config isn’t right or something
  14. How to fix:
    1) Forget the idea for custom source roots and remove it, and drag the package into the "java" folder inside the "main" folder.
    2) Add a line to include the "plugin.yml" manually - I used to do it too, which is why I know this.

    My tip: forget about custom source roots - it's annoying and makes you add more stuff manually.
  15. His plugin yml is already inside the jar file this isn’t the issue. As shown on the screen the server reads the plugin.yml but cannot find the main file as specified inside plugin.yml
  16. So rebuild the plugin after changing stuff. Maybe. IDK. I think that's how coding works? :p