Solved Cannot find class?

Discussion in 'Spigot Plugin Development' started by xImprovable, Apr 26, 2017.

  1. [12:59:53 ERROR]: Could not load 'plugins\ChatClear.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.ximprovable.cc.ChatControl'
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.craftbukkit.v1_11_R1.CraftServer.loadPlugins(CraftServer.java:301) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.craftbukkit.v1_11_R1.CraftServer.reload(CraftServer.java:748) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.Bukkit.reload(Bukkit.java:540) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.craftbukkit.v1_11_R1.CraftServer.dispatchCommand(CraftServer.java:650) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.craftbukkit.v1_11_R1.CraftServer.dispatchServerCommand(CraftServer.java:636) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at net.minecraft.server.v1_11_R1.DedicatedServer.aM(DedicatedServer.java:437) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot.jar:git-Spigot-38ddb34-c19c293]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
    Caused by: java.lang.ClassNotFoundException: me.ximprovable.cc.ChatControl
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_131]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot.jar:git-Spigot-38ddb34-c19c293]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-38ddb34-c19c293]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_131]
    at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_131]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-38ddb34-c19c293]
    ... 15 more

    I get this error when I start my server. I made my plugin and I popped it into the plugins folder and I got this message. I dont know what to do. If you want code ect just ask
     
  2. Yeah I know I dont know what to say?
     
  3. I dont know what you mean?
     
  4. Show us your plugin.yml, it should have a main, a name, and a version.
     
  5. This has nothing to do with dependencies, if you both read the error, your plugin.yml is not pointing to the main class. Either that or your compilation isn't correct and the jar isn't being built properly.

    I linked the thread specifically for the sections "Know your Java" and "Give us sample code + stacktrace"
     
    • Agree Agree x 2
    • Like Like x 1
    • Winner Winner x 1
  6. Make sure the main class that extends JavaPlugin is called ChatControl, and is under the pacakage name 'me.ximprovable.cc'. If it is not, there is your issue. Update it in your plugin.yml, or refactor the package/class name to suit.
     
  7. WAS

    WAS

    Also, you do not need to depend on a plugin to load before it. There is specifically a loadbefore option for your plugin.yml
     
  8. loadbefore and depend are polar opposites iirc. loadbefore states that your plugin should load before the plugins listed, while depend states that the plugins listed should load before yours.
     
    • Agree Agree x 1
  9. WAS

    WAS

    Right. That's true.