Cannot find main class ct.jqmsg.Main

Discussion in 'Spigot Plugin Development' started by ComboTombo, Jul 12, 2018.

  1. So, here's the error log. It says that there's no main class called ct.jqmsg.Main but there actually is one. Look here:
    : Could not load 'plugins\JoinQuitMessage.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `ct.jqmsg.Main'
    at<init>( ~[Spigot.jar:git-Spigot-550ebac-7019900]
    at ~[Spigot.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin( ~[Spigot.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins( [Spigot.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins( [Spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.DedicatedServer.init( [Spigot.jar:git-Spigot-550ebac-7019900]
    at [Spigot.jar:git-Spigot-550ebac-7019900]
    at Source) [?:1.8.0_171]
    Caused by: java.lang.ClassNotFoundException: ct.jqmsg.Main
    at Source) ~[?:1.8.0_171]
    at ~[Spigot.jar:git-Spigot-550ebac-7019900]
    at ~[Spigot.jar:git-Spigot-550ebac-7019900]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_171]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_171]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_171]
    at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_171]
    at<init>( ~[Spigot.jar:git-Spigot-550ebac-7019900]
    ... 7 more]


    Here's my plugin.yml file:
    main: ct.jqmsg.Main
    name: JoinQuitMessage
    version: 1.0
    author: ComboTombo
    description: This plugin will send a message when a player joins/leaves the server.
  2. Is it shaded into it?
  3. Would you mind showing us the Main class code?
  4. the plugin.yml has to be in the src folder and your main class has to extend JavaPlugin
  5. The plugin.yml doesn't have to be in the src folder. Simply being in the project is enough.
  6. When you decompile your plugin, what does it show?
  7. The sources are the only package which will be compiled from your own source code, you must keep your plugin.yml within the sources - but they dont need to be in your own package. Some development environments would allow you setup grabbing the plugin yml from the outside, but that doesn't happen by default.
  8. The plugin.yml is included, else spigot will throw an Exception that it didn’t found the plugin.yml
  9. Just realized that the eclipse layout scopes in a different manner, in my IDE you work with /java/src/ which still falls under the sources.
  10. MiniDigger


    sane ppl would use a sane project layout like this to make that way more clear
  11. Can just say one thing here:

  12. I see Eclipse icon, I leave thread.
    • Like Like x 1
    • Funny Funny x 1
  13. That's how Maven is setup. Works well for me.
  14. MiniDigger


    thats also how gradle works, or any sane project should be layed out.
  15. Your class needs to extend JavaPlugin. Just add an "extends JavaPlugin" between Main and the open curly bracket and import it.

    I don't like Eclipse either, but it doesn't make you a worse developer. Minecraft was also coded in Eclipse.
  16. Is it shaded into it?[/QUOTE]
    Ty for the replies, and here's a snippet of the code:
    package ct.jqmsg;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;

    public class Main extends JavaPlugin implements Listener {
  17. The whole code if possible? And refrain from using "Main" as your core class. I can only assume you've misplaced the plugin.yml folder OR you have not added an onEnable method on your class which extends javaPlugin.
  18. 1. Putting the plugin.yml in src folder is totally fine. If ur compiler compiles ur jar correctly the plugin.yml will be at the root dir of the compiled jar.

    2. A JavaPlugin subclass does not need to override onEnable.

    There may be three possibilities:
    1. The problem is not about no main class
    2. You showed us fake information
    3. The compiler has problems
  19. MiniDigger


    just open the jar as a zip and look if the structure is right
  20. [​IMG]

Share This Page