I'm currently having a maven project with multiple dependencies (which are included in the jar) and one single dependency which lays somewhere else also compiled as a jar file. Now I'm trying to load classes dynamically in my project, a simple class like this would work:
public class test {
static {
System.out.println("SUCCESS!");
}
}
but as soon as my class is trying to inteact with my project it says that the external dependency could not be resolved. Is there a way to automatically include all dependencies of the project into my classpath when I'm compiling? (I'm already adding the project.jar) Or is there an other way to compile it and execute this class without this problem?
EDIT: It's now compiling because I added the jar manually to my classpath, but I'm getting a runtime exception now
My class:
import be.multicu.core.MultiCube;
public class Debug {
public void debug() {
System.out.println(MultiCube.getInstance().getCurrentServer().getOnlinePlayers());
}
}
The exception (note: the log is reversed!):
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_51]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
at be.multicu.core.util.Debugger.debugFromPastebin(Debugger.java:54) [MultiCubeCore.jar:?]
at be.multicu.core.command.commands.debug.run(debug.java:68) [MultiCubeCore.jar:?]
at be.multicu.core.command.BaseCommand.onCommand(BaseCommand.java:55) [MultiCubeCore.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:724) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:985) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:830) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:65) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:176) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.ServerConnection.c(ServerConnection.java:77) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:713) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:283) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:576) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:482) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftcubbit.jar:git-Spigot-1.7.2-R0.3-178-g45eab08]
Caused by: java.lang.NoClassDefFoundError: be/multicu/core/MultiCube
at Debug.debug(Debug.java:6) ~[?:?]
... 21 more
Caused by: java.lang.ClassNotFoundException: be.multicu.core.MultiCube
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[?:1.7.0_51]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[?:1.7.0_51]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_51]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[?:1.7.0_51]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_51]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_51]
at Debug.debug(Debug.java:6) ~[?:?]
... 21 more
Thanks for the help, Joba