问题描述:

I'm having trouble including a JAR file that adds a class that will let my main class send emails.

What I have done...

  • Saved the EmailAPI.jar file in my folder, as mentioned in below POM text (and it finds it, because in NetBeans I can explore the class)
  • Updated the dependency in my POM file, as follows:

    <dependency>

    <groupId>EmailAPI</groupId>

    <artifactId>EmailAPI</artifactId>

    <version>1.0</version>

    <scope>system</scope>

    <systemPath>${basedir}\src\lib\EmailAPI.jar</systemPath>

    </dependency>

  • Add the import (NetBeans automatically added this when I used the Email class, so it seems to know where to look...)

    import me.nrubin29.emailapi.Email;

  • Call the class, directly using the structure provided

    //send an email

    new Email()

    .withSMTPServer("smtp.gmail.com")

    .withUsername("[email protected]")

    .withPassword("xxxxxxx")

    .withTo("[email protected]; [email protected]")

    .withSubject("[RP] Server has started")

    .withBody("This is the body!")

    .send();

I can build fine, it all works out... but then when I try to run it (as a plugin to Minecraft), I get a NoClassDefFoundError, as shown here:

http://pastebin.com/V33gCLVG

I don't understand what I'm missing here. Can anyone point me in the right direction?

网友答案:

You use <scope>system</scope>. Is it available in the Minecraft enviroment? See Maven, Introduction to the Dependency Mechanism, Dependency Scope: "This scope is similar to provided [...] " and under provided: "indicates you expect [...] a container to provide the dependency at runtime."

网友答案:

It means that you are missing the jar in your runtime environment. You might need to change the scope of your maven dependency to compile.

网友答案:

EmailAPI requires two JARs in order to run. I think they are activation and mail or something. I can look at the project but I think you might be missing them.

相关阅读:
Top