Hi I've been dealing with this for a bit now and I haven't been able to fix it.
So I have a simple Java application which uses the Google Calendar API to get events from it.
When I run it on the IDE(IntelliJ) it works with no errors but when I build and run the the JAR from the command line I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/api/client/extensions/java6/auth/oauth2/VerificationCodeReceiver
at info.cantu.smartmirror.Main.main(Main.java:44)
Caused by: java.lang.ClassNotFoundException:
com.google.api.client.extensions.java6.auth.oauth2.VerificationCodeReceiver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I imported the required libraries using maven. I think I may be building the jar wrong.
Here's my MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: info.cantu.smartmirror.Main
Here is what my Artifacts panel looks like:
Any ideas?
Okey I figured it out. I did two things:
Number 1: I removed the google-oauth-client-jetty:1.20.0 from the project by going to Project Structure -> Libraries -> (selecting it) -> clicking the minus button.
Then I added the new version of the library (1.22) this link has the latest version number. I Added it through maven by (in the same window as before) clicking the plus button -> From Maven and searching for it
However it did not seem to work.
Number 2(I THINK THIS DID THE TRICK):
In Project Structure -> Artifacts -> The JAR I was trying to build -> I selected the library with the issue on the the right. However, instead of double clicking it which simply puts the library in the output root. I right clicked and selected "Extract Into Output Root" which extracted all the individual jars included in the library and added them to the output root.
As shown below
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With