[Java] DiscordAPI can't be found. (Build using Maven)

java

#1

I am writing my discord bot using java, I made a file called ‘glitch.json’ containing this: https://pastebin.com/raw/0XVtC45k
The pom.xml contains this: https://pastebin.com/raw/vqXT1fBK

Sadly even after trying this it still gives the error of not being able to find the dependency:

Exception in thread "main" java.lang.NoClassDefFoundError: net/dv8tion/jda/core/JDABuilder
at nl.fortune.DiscordBott.BotCore.main(BotCore.java:21)
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.core.JDABuilder
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

(Only able to post 2 links in one post, since I am new. Sorry for that it must be done this way)

I am honestly confused on what to try next. I hope you have any idea on how to make this work! Thanks for your time reading this


MOD EDIT: formatting


#2

Hey @Naomiora, welcome to the Glitch Forums!

I understand you’ve found the solution to your problem - would you be willing to share what you found here? Particularly for languages we don’t officially support it’s helpful when Glitch community members can help each other out, and someone else might find something useful from reading your solution next week (or next year).

Thanks and happy Glitching!


#3

Hey,

The problem was, I was shading the .jar as seen in the pom.xml. The file with dependencies was eventually ‘final-(name+version)-shaded.jar’ which glitch didn’t start, it only started ‘(name+version)’. What I did is I removed the shade plugin from my pom.xml and replaced it with this:

			<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-dependency-plugin</artifactId>
			<version>2.4</version>
			<executions>
				<execution>
					<id>copy-dependencies</id>
					<phase>compile</phase>
					<goals>
						<goal>copy-dependencies</goal>
					</goals>
				</execution>
			</executions>
		</plugin>

Which made my project run w/ dependencies!