[英]java NoClassDefFoundError: com/google/api/client/extensions/java6/auth/oauth2/VerificationCodeReceiver when I run jar but not on IDE
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. 所以我有一个简单的Java应用程序,它使用Google Calendar API从中获取事件。
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: 当我在IDE(IntelliJ)上运行它时没有错误,但是当我从命令行构建并运行JAR时,我收到此错误:
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. 我使用maven导入了所需的库。 I think I may be building the jar wrong.
我想我可能会错误地构建jar。
Here's my MANIFEST.MF: 这是我的MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: info.cantu.smartmirror.Main
Here is what my Artifacts panel looks like: 这是我的Artifacts面板的样子:
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. 1号:我从项目中删除了google-oauth-client-jetty:1.20.0,进入项目结构 - >库 - >(选择它) - >点击减号按钮。
Then I added the new version of the library (1.22) this link has the latest version number . 然后我添加了新版本的库(1.22) 这个链接有最新的版本号 。 I Added it through maven by (in the same window as before) clicking the plus button -> From Maven and searching for it
我通过maven添加它(在与之前相同的窗口中)单击加号按钮 - >从Maven并搜索它
However it did not seem to work. 但它似乎没有用。
Number 2(I THINK THIS DID THE TRICK): 2号(我认为这是诡计):
In Project Structure -> Artifacts -> The JAR I was trying to build -> I selected the library with the issue on the the right. 在项目结构 - >工件 - >我试图建立的JAR - >我选择了右边有问题的库。 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.
我右键单击并选择“Extract Into Output Root”,它提取了库中包含的所有单个jar并将它们添加到输出根。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.