title: Get unique file id in Windows with Java?
body: <p>I'm looking for a way to get a unique file id in a Java application, and came across this:</p>
  
  <p><a href="https://stackoverflow.com/questions/1866454/unique-file-identifier-in-windows">Unique file identifier in windows</a></p>
  
  <p>Now, I tried the answer supplied by Ashley Henderson himself (the one that asked the question), and that worked fine in C#. But I need to do this in Java, in order to have the app work across platforms.</p>
  
  <p>Is there any way to port this to Java, or get to the same id some other way?</p>
  
  <p>EDIT:</p>
  
  <p>I almost got it working now, using the solution by eee, only I need it to be in a library, and when I compile it as a library I get an error, even though everything is working fine in a test application with everything included. But with a separate library that I try to import (no compiler errors) I get this runtime error:</p>
  
  <pre><code>debug:
  Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Structure
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at winfileid.FileId.getFileId(FileId.java:37)
      at testfileid.TestFileId.main(TestFileId.java:19)
  Caused by: java.lang.ClassNotFoundException: com.sun.jna.Structure
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      ... 14 more
  Java Result: 1
  BUILD SUCCESSFUL (total time: 0 seconds)
  </code></pre>
  
  <p>I've included the jna.jar and platform.jar in the library when I compiled it... Please note again that I'm very new to Java, but what am I doing wrong?</p>