question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Shell32

See original GitHub issue

I am using appdirs in a JavaFX application. appdirs throws exception in Windows 7 as below:

Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        ... 5 more
java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Shell32
        at net.harawata.appdirs.impl.ShellFolderResolver.resolveFolder(ShellFolderResolver.java:38)
        at net.harawata.appdirs.impl.WindowsAppDirs.getLocalAppData(WindowsAppDirs.java:71)
        at net.harawata.appdirs.impl.WindowsAppDirs.getUserDataDir(WindowsAppDirs.java:33)
        at net.harawata.appdirs.AppDirs.getUserDataDir(AppDirs.java:28)
        at com.erayerdin.corpustk.App.<clinit>(App.java:19)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$155(LauncherImpl.java:352)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformI
mpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.platform.win32.Shell32
        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)
        ... 16 more

It works in Linux, though. Adding com.sun.jna as a Maven dependency does not work as well.


Environment

  • Microsoft Windows [Version 6.1.7601] (stands for Windows 7)
  • Java™ SE Runtime Environment (build 1.8.0_151-b12)
  • Appdirs 1.0.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
zak-pawelcommented, Nov 15, 2017

I can confirm that 1.0.1 solves problem. Thanks!

2reactions
harawatacommented, Nov 15, 2017

@erayerdin ,

No worries. I appreciate you took the time to report this!

@zak-pawel is right (thanks for the help!). I checked the dependency and it is jna-platform that is required by appdirs (jna is also required, but it will be automatically added because jna-platform depends on it).

Anyway, to make things simpler, I have modified the scope of jna-platform dependency to compile and released 1.0.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webdriver error : java.lang.NoClassDefFoundError: com/sun ...
Your issue is due to missing jar that contains : com/sun/jna/platform/win32/Kernel32. You should be able to download it with its dependency here:.
Read more >
Could not initialize class com.sun.jna.Native - Google Groups
java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native at com.sun.jna.platform.win32.Shell32.<clinit>(Shell32.java:32)
Read more >
issues with "com/sun/jna/platform/win32/Win32Exception ...
7, I am facing java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Win32Exception for my couple of flows, which was working fine earlier.
Read more >
jna-platform 5.12.1 javadoc (net.java.dev.jna)
Provides common library mappings for COM Type Library implementations. com.sun.jna.platform.win32.COM.util. Provides COM Utilities. com.sun.jna.
Read more >
com/sun/jna/Platform with FileBot 4.9.0 and Fedora 31
BluRay.H264.AAC-RARBG..mp4] com/sun/jna/Platform java.lang.NoClassDefFoundError: com/sun/jna/Platform at net.filebot.MetaAttributeView.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found