Hey guys, quick question. If I'm using a library I created and I want to reference a class from within it at runtime how do I do so? Right now I'm using a class loader. Here's the code: Code:java ClassLoader classLoader = Main.class.getClassLoader();try {Class aClass = classLoader.loadClass("me.JBoss925.com.Api");System.out.println("aClass.getName() = " + aClass.getName());} catch (ClassNotFoundException e) {e.printStackTrace();} Here's the stack trace: Code: [17:40:03 ERROR]: Could not pass event ProjectileLaunchEvent to Golden Touch v1.0 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectileLaunchEvent(CraftEventFactory.java:597) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.World.addEntity(World.java:904) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.World.addEntity(World.java:871) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ItemBow.a(ItemBow.java:59) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ItemStack.b(ItemStack.java:319) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.EntityHuman.by(EntityHuman.java:103) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:498) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PacketPlayInBlockDig.a(SourceFile:53) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PacketPlayInBlockDig.handle(SourceFile:8) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] Caused by: java.lang.NoClassDefFoundError: me/JBoss925/com/Api at me.JBoss925.goldtouch.Main.onPlayerShoot(Main.java:102) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65] at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] ... 19 more Caused by: java.lang.ClassNotFoundException: me.JBoss925.com.Api at java.net.URLClassLoader$1.run(URLClassLoader.java:202) ~[?:1.6.0_65] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.6.0_65] at java.net.URLClassLoader.findClass(URLClassLoader.java:190) ~[?:1.6.0_65] at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) ~[?:1.6.0_65] at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[?:1.6.0_65] at me.JBoss925.goldtouch.Main.onPlayerShoot(Main.java:102) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65] at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] ... 19 more > As you can see it's not finding the class. Must I specify differently? I am also packaging my api library with my plugin when I make it.
There are methods in my library I need to get. I can import them during the coding portion but then when it goes to run the method I used it says it can't find my Api class.
The reason it can't find your API is because it isn't there at runtime. Your API needs to either be a plugin that is installed on the server or packaged inside of the plugin that is trying to access the methods.