Error: JavaPlugin cannot be resolved to a type

Discussion in 'Plugin Development' started by CheeseKeg, Jul 16, 2011.

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

    CheeseKeg

    Hey, thanks for taking a look at this thread for me.

    I'm fairly inexperienced with Java and unfamiliar with Eclipse, so I decided that the best way to begin working with the Bukkit API was to begin with this tutorial (sort of).

    After obtaining the source for both CraftBukkit and Bukkit via EGit, I imported Bukkit as a Maven project, proceeding to create another Java Project which incorporates Bukkit within it's build path.

    Everything beyond this is clearly visible within the image below:
    [​IMG]

    I'm not entirely sure why, but the above image displays an apparent error which I'm having trouble understanding in the context of my test project.

    Please correct me if I'm wrong, but doesn't this error indicate that JavaPlugin is beyond the scope of TestPlugin? Given the fact that I've added Bukkit to TestPlugin's build path, wouldn't that introduce every public Bukkit class into the scope of TestPlugin?
    Anyhow, if the above is correct (which I don't expect that it is) -- Adding "include org.bukkit.*" didn't seem to do me any good.

    Also, Google searches are telling me that there are some bugs within Eclipse pertaining to the "Project >> Build Automatically" option that causes this to occur at seemingly random times, but me being inexperienced with the Bukkit API tells me that the title of this post is likely going to ring a loud bell to someone who's going to proceed to (constructively) yell at me!

    So please, Bukkit aficionados, go ahead and wreak havoc on my post, for me; constructively, of course.

    Thanks in advance,
    - Brandon.
     
  2. Offline

    Zaven

    Hello. I'm also new to this but I'm pretty sure your problem is that you didn't put this lane:

    import org.bukkit.plugin.java.JavaPlugin;

    before your main class declaration. In this case, that would be :

    Code:
    package me.CheeseKeg.TestPlugin;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class TestPlugin extends JavaPlugin {
    
        public void onEnable(){
        }
    
        public void onDisable(){
        }
    
    }
    

    Just FYI, by clicking on the error icon, you should read " Import 'JavaPlugin' (org.bukki.plugin.java) ".
    Double clicking on this, will put the needed line. It's just a way to gain some time, you can type the line yourself.
     
    CheeseKeg likes this.
  3. Have you tried adding the Bukkit.jar file to your build path?
     
  4. Offline

    CheeseKeg

    Ah, geez. That's sort of what I tried to do above, but I figured as time goes on, I would have to import other classes and such. Where I'm coming from, it's actually considered to be more sound to import everything, whether you're going to use it or not. This is probably not the case for Java.
    TL;DR, this worked. Thank you. :)

    That's where I went a little differently from the tutorial; I've always had a need to compile as many dependencies that as possible within a 'build list' (or the 'build path', as Eclipse calls it) before incorporating them into a final solution. Working with the source of Bukkit will likely help me debug more effectively in the future, given that I'll simply be able to look at the source if something fire's an exception within Bukkit (as in, the stack trace begins there) and determine the correct way to utilize it (or report a bug/fix it).
    This shouldn't be a problem, but it's certainly a different approach then given by the tutorial I mentioned I was following.

    Thanks for the help!
    - Brandon.

    Just to document an issue I had after this for other newcomers who are trying out this same setup:

    I had another problem on a similar note (as it was still hindering my ability to compile). Eclipse was yelling at me, explaining that it couldn't find ebean classes because it wasn't in the build path for Bukkit.... but it was.
    [​IMG]

    It turns out that within the "Order and Export" tab, the Maven dependencies weren't checked off:
    [​IMG]

    Cheers,
    - Brandon.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
Thread Status:
Not open for further replies.

Share This Page