ClassNotFoundException?

Discussion in 'Plugin Development' started by Set3, Jun 21, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Set3

    So I'm trying to write a plugin, and I'm very new to java development. I am trying to understand why I'm getting a ClassNotFoundException. Heres the error message:
    Code:
    [19:58:54 ERROR]: Could not load 'plugins/AdvMute.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.gmail.stownander.AdvMute.AdvancedMute'
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigot.jar:git-Spigot-798f32d-0cd0397]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-798f32d-0cd0397]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-798f32d-0cd0397]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot.jar:git-Spigot-798f32d-0cd0397]
        at org.bukkit.craftbukkit.v1_9_R2.CraftServer.loadPlugins(CraftServer.java:297) [spigot.jar:git-Spigot-798f32d-0cd0397]
        at net.minecraft.server.v1_9_R2.DedicatedServer.init(DedicatedServer.java:200) [spigot.jar:git-Spigot-798f32d-0cd0397]
        at net.minecraft.server.v1_9_R2.MinecraftServer.run(MinecraftServer.java:532) [spigot.jar:git-Spigot-798f32d-0cd0397]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]
    Caused by: java.lang.ClassNotFoundException: com.gmail.stownander.AdvMute.AdvancedMute
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_92]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot.jar:git-Spigot-798f32d-0cd0397]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-798f32d-0cd0397]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_92]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_92]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_92]
        at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_92]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-798f32d-0cd0397]
       ... 7 more
    
    Here's the class:
    Code:
    package com.gmail.stownander.AdvMute;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class AdvancedMute extends JavaPlugin{
        public void onEnable() {
            this.getCommand("votemute").setExecutor((CommandExecutor) new VoteMuteCommand());
        }
    }
    Plugin.yml:
    Code:
    main: com.gmail.stownander.AdvMute.AdvancedMute
    name: AdvMute
    version: 0.1
    author: [email protected]
    description: advanced mute commands
    commands:
        votemute:
            description: Starts a vote to temp mute a player
            usage: /votemute <player>
    I understand this should be really simple to fix, but I'm really struggling to see what I'm doing wrong...
     
  2. Offline

    CeramicTitan Retired Staff

    This makes no sense.

    Can you show your project hierarchy via screenshot pls? @Set3
     
    Last edited: Jun 21, 2016
  3. Offline

    Set3

    Sorry forgot to include that:
    Screen Shot 2016-06-21 at 9.16.27 PM.png
     
    Last edited: Jun 21, 2016
  4. Offline

    Zombie_Striker

    @Set3
    Are you sure you packaged it correctly? Try opening up your .jar file with Winrar or 7zip and see if the main class is in the correct path.
     
  5. Offline

    CeramicTitan Retired Staff

    @Set3 Have you ever used maven before? Because I think your issue may be a pom issue or a build issue.
     
    Last edited: Jun 22, 2016
    bwfcwalshy likes this.
Thread Status:
Not open for further replies.

Share This Page