简体   繁体   English

java NoClassDefFoundError:com / google / api / client / extensions / java6 / auth / oauth2 / VerificationCodeReceiver当我运行jar而不是IDE时

[英]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面板的样子:

这是我的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并将它们添加到输出根。

As shown below 如下所示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java Jar -java.lang.NoClassDefFoundError: com.google.api.client.http.HttpTransport from - Java Jar -java.lang.NoClassDefFoundError: com.google.api.client.http.HttpTransport from 使用Java访问Google Drive API会引发com.google.api.client.auth.oauth2.TokenResponseException:401 - Accessing google drive api with java throws com.google.api.client.auth.oauth2.TokenResponseException: 401 Apache POI Java程序在IDE(Eclipse)中运行良好,但是当我尝试将其作为可运行的jar运行时遇到NoClassDefFoundError - Apache POI Java program working fine in IDE (Eclipse) but encounter NoClassDefFoundError when I tried to run it as a runnable jar com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request Invalid Grant java Console Application - com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request Invalid Grant java Console Application java.lang.ClassNotFoundException:com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier$Builder - java.lang.ClassNotFoundException: com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier$Builder 如何在 com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver 中设置自定义 RedirectUri - How to set a custom RedirectUri in com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver java.lang.NoClassDefFoundError:com / google / api / client / json / JsonFactory - java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer - java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer com.google.api.client.extensions.java6无法解析 - com.google.api.client.extensions.java6 cannot be resolved NoClassDefFoundError:com / google / api / client / extensions / appengine / http / UrlFetchTransport? - NoClassDefFoundError: com/google/api/client/extensions/appengine/http/UrlFetchTransport?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM