Skip to content
Advertisement

Errors with importing JavaPlugin to Eclipse

I want to make a plugin for Minecraft, but I have problem with importing JavaPlugin into Eclipse. When I type

import org.bukkit.java.plugin.java.JavaPlugin;

I get these 2 errors.

The import java.plugin cannot be resolved
JavaPlugin cannot be resolved to a type

I have tried restarting my computer, reinstalling Eclipse, downloading all over again but nothing works. I am sending

a link to a screenshot.

https://paste.pics/GHDFU

Please help, Thank you in advance.

Advertisement

Answer

First make sure you didn’t make any typos in your import statement.

If that didn’t fix it there are 2 possible solutions I can think of:

Solution 1

You probably haven’t added this plugin to your classpath inside of the java project.

To do this right-click on your project (inside of the project explorer) and press Properties.

If you’ve done everything correctly there should popup another window where you can search for “Java Build Path”.

Click on it and then go to the Libraries tab. Since I don’t know what file type the plugin is I’m assuming it’s a .jar file. Click on the “Add JARs” button and select the plugin file.

Solution 2

If you use a maven project you probably haven’t configured the plugin dependency inside your pom.xml file.

Just open the file and add the dependency. In the end it could look like this:

<dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>2.0.0-alpha5</version>
        <scope>runtime</scope>
</dependency>

I hope I understood your problem correctly and this answer helps you to solve this problem.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement