MinnDevelopment / java-discord-rpc

Java bindings for https://github.com/discordapp/discord-rpc (using JNA)
Apache License 2.0
132 stars 38 forks source link

Can't find class definitions #9

Closed willeccles closed 6 years ago

willeccles commented 6 years ago

When using javac -cp lib/<discord-rpc>.jar:. <main>.jar (obviously with the real names), the compilation has no issues and finishes just fine. However, when I try to run the app using java -cp <same classpath> <main>.class, it gives me:

Exception in thread "main" java.lang.NoClassDefFoundError: club/minnced/discord/rpc/DiscordRPC
    at mainGame.Game.<init>(Game.java:135)
    at mainGame.Game.main(Game.java:408)
Caused by: java.lang.ClassNotFoundException: club.minnced.discord.rpc.DiscordRPC
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

Not sure why this is, since the compiler had no issue with it. If I switch the line with the one after it (instantiating my DiscordEventHandlers), it's the same error but with the DiscordEventHandlers class, so it's not limited only to DiscordRPC. Any clue what's wrong? 100% could be a user error, I don't do too much with external libs, so I might be doing something wrong.

willeccles commented 6 years ago

Well, I am an idiot. Forgot that the .jar itself was not what needed to be in the classpath, but rather the directory it's in, so in this case lib/.