axet/desktop: Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform
axet/desktop: Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform
我正在从存储库 https://github.com/axet/desktop/tree/master/java 构建项目。我正在尝试 运行 DesktopTest class。我这样做:
$ mvn package
$ cd target
$ java -cp ./desktop-2.3.3.jar:.:test-classes/ com.github.axet.desktop.DesktopTest
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform
at com.github.axet.desktop.Desktop.getDesktopFolders(Desktop.java:53)
at com.github.axet.desktop.Desktop.getHomeFolder(Desktop.java:32)
at com.github.axet.desktop.DesktopTest.main(DesktopTest.java:10)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Platform
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
我做错了什么?
Java版本:
$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
您还没有下载软件包的依赖项。它们列在 pom.xml
文件中。但是您不必担心手动执行此操作。
而不是简单地使用 mvn package
你应该执行:
$ mvn clean dependency:copy-dependencies package
这会将所有需要的 jar 复制到 target/dependency
目录中。将该目录添加到您的类路径中,它应该可以工作,例如,
$ java -cp ./desktop-2.3.3.jar:.:test-classes/:dependency/* com.github.axet.desktop.DesktopTest
我正在从存储库 https://github.com/axet/desktop/tree/master/java 构建项目。我正在尝试 运行 DesktopTest class。我这样做:
$ mvn package
$ cd target
$ java -cp ./desktop-2.3.3.jar:.:test-classes/ com.github.axet.desktop.DesktopTest
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform
at com.github.axet.desktop.Desktop.getDesktopFolders(Desktop.java:53)
at com.github.axet.desktop.Desktop.getHomeFolder(Desktop.java:32)
at com.github.axet.desktop.DesktopTest.main(DesktopTest.java:10)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Platform
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
我做错了什么?
Java版本:
$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
您还没有下载软件包的依赖项。它们列在 pom.xml
文件中。但是您不必担心手动执行此操作。
而不是简单地使用 mvn package
你应该执行:
$ mvn clean dependency:copy-dependencies package
这会将所有需要的 jar 复制到 target/dependency
目录中。将该目录添加到您的类路径中,它应该可以工作,例如,
$ java -cp ./desktop-2.3.3.jar:.:test-classes/:dependency/* com.github.axet.desktop.DesktopTest