如何修复“线程“主”java.lang.NoClassDefFoundError 中的异常:

如果更有经验的 StackOverflow 用户可以建议如何使问题更容易理解,请这样做。

我正在使用 Eclipse Maven 进行编译和来自https://github.com/dropbox/dropbox-sdk-java的示例,更具体地说是授权示例,因此当我获取所有代码并将其放入时,我可以生成和授权文件一个新的 Maven 项目并在 sdk 中链接到库它仍然报告错误有问题的错误读取〜

C:\Authoriser\my-app>java -jar C:\Authoriser\my-app\target\my-app-1.0-SNAPSHOT.jar

Error: A JNI error has occurred, please check your installation and try again

Exception in thread "main" java.lang.NoClassDefFoundError: com/dropbox/core/json/JsonReader$FileLoadException

        at java.lang.Class.getDeclaredMethods0(Native Method)

        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)

        at java.lang.Class.privateGetMethodRecursive(Unknown Source)

        at java.lang.Class.getMethod0(Unknown Source)

        at java.lang.Class.getMethod(Unknown Source)

        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)

        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

Caused by: java.lang.ClassNotFoundException: com.dropbox.core.json.JsonReader$FileLoadException

        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)

        ... 7 more

到目前为止,我已经尝试移动 lib 文件并查看了有关堆栈溢出的其他解决方案,但是大多数似乎都处于不同的上下文中,或者我更加无能。“类似问题”提示的问题包括 Exception in thread "main" java.lang.NoClassDefFoundError: com/twitter/chill/KryoBase 和Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonParseException 然而这些都是在完全不同的背景下,我在 github 上问了更多,但没有任何回应(还)。



慕标5832272
浏览 157回答 1
1回答

胡子哥哥

我刚刚pom.xml为. 把它放在下面,看看你能不能带着它去任何地方:authorizedropbox-sdk-javahttps://github.com/dropbox/dropbox-sdk-java/tree/master/examples/authorize<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&nbsp; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">&nbsp; <modelVersion>4.0.0</modelVersion>&nbsp; <groupId>com.mycompany.app</groupId>&nbsp; <artifactId>my-app</artifactId>&nbsp; <packaging>jar</packaging>&nbsp; <version>1.0-SNAPSHOT</version>&nbsp; <name>my-app</name>&nbsp; <url>http://maven.apache.org</url>&nbsp; <dependencies>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.dropbox.core</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>dropbox-core-sdk</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>3.1.1</version>&nbsp; &nbsp; </dependency>&nbsp; </dependencies>&nbsp; <build>&nbsp; &nbsp; <plugins>&nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>maven-shade-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>3.2.0</version>&nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!-- Attach the shade into the package phase -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>package</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>shade</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transformers>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <mainClass>com.dropbox.core.examples.authorize.Main</mainClass>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transformer>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transformers>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; </executions>&nbsp; &nbsp; &nbsp; </plugin>&nbsp; &nbsp; </plugins>&nbsp; </build></project>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java