ClassNotFoundException error when i import something.

Discussion in 'Plugin Development' started by AnniKa, Jul 2, 2012.

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

    AnniKa

    Hey, i wanted to start again with making some plugins for my little server :)

    but there is a problem now that was not there before.
    this one is working fine:
    i just made it for a small test.

    Code:
    package me.annixa.npcroom;
         
    import org.bukkit.plugin.java.JavaPlugin;
         
        public class npcroom extends JavaPlugin {
         
        	public void onEnable(){
        		getLogger().info("NPCroom on");
        	}
         
        	public void onDisable(){
        		getLogger().info("NPCroom off");
        	}
         	
        }
    
    this works fine and i cann see the "NPCroom on" message in console.
    but when i just add any import like
    import org.bukkit.entity.Player;
    then i get a ClassNotFoundException error.

    what did i made wrong here?
     
  2. exception? the code thats not working?
     
  3. Offline

    sayaad

    Is the bukkit version for the server the same as the one imported in your java ide?
     
  4. Offline

    EnvisionRed

    Did you add the bukkit.jar as a source?
     
  5. Offline

    Assult

    maybe this will work

    Code:
    package me.annixa.npcroom;
       
    import org.bukkit.plugin.java.JavaPlugin;
       
        public class npcroom extends JavaPlugin {
     
        public Logger log = Logger.getLogger("Minecraft");
     
            public void onEnable(){
               this.log.info("NCProom on");
            }
       
            public void onDisable(){
                this.log.info("NCProom off");
            }
           
        }
    
     
  6. Assult
    Totally unrelated and it's not recommended, the this.getLogger() (from JavaPlugin) is the recommended way... but do not asign that to a field because it's unavailable before onEnable() triggers.

    AnniKa
    You should show the code you tried with and the full stacktrace you got.
     
  7. Offline

    AnniKa

    Sorry for my bad explaining, what i mean is that the code above there is working finde.

    but when i just add the line "import org.bukkit.entity.Player" (or any other import org.bukkit.*)
    so that the whole code is like this:

    Code:
    package me.annixa.npcroom;
         
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.entity.Player;      // <-------- this is new, without this it is working all fine
    
        public class npcroom extends JavaPlugin {
         
        	public void onEnable(){
        		getLogger().info("NPCroom on");
        	}
         
        	public void onDisable(){
        		getLogger().info("NPCroom off");
        	}
         	
        }
    
    then it is not working anymore.

    the error:
    and to be sure my config.yml:

    Code:
    name: me.annixa.npcroom
    main: me.annixa.npcroom.npcroom
    version: 01
    
     
  8. Why do you even want to import something you're not using ? I even suspect your IDE is underlining that.

    But that error seems to be related to something else... maybe class name fault ? Classes should start with a capital letter, try with "NPCRoom" or something :p
     
  9. Offline

    AnniKa

    of course i had alot more code before that used player =)
    but i removed it all to find the error.
    even when i use player anyhow its not working.

    I tried with Npcroom also, same problem :( just named all small to finde the problem
    using the Name convention is not a "must be" as far as i know.

    Yes, eclipse also tell me that i need to import entity.player when i use Player stuff, so i think that worked.

    yes, its all 1.2.5-R4.0

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  10. What error ? What code ?

    You're assuming something is the problem when it could not be... just show what your initial problem and code was.
     
Thread Status:
Not open for further replies.

Share This Page