title: Get File Version of .exe in java on Linux
body: <p>Question - Get File Version of .exe in java on Linux for some strange client.</p>
  
  <p>Solution - </p>
  
  <p>I used JNA library to read file version using Java. Given below code is running fine on windows platform but it is throwing below error on Linux docker image.</p>
  
  <p>"Unable to load library 'version': Error loading shared library libversion.so: No such file or directory Error loading shared library libversion.so: No such file or directory Native library (linux-x86-64/libversion.so) not found in resource path..".</p>
  
  <pre><code>private String GetFileVersion(String filePath) {
  
      File fileToCheck = new File(filePath);
      short[] rtnData = new short[4];
  
  
      int infoSize = Version.INSTANCE.GetFileVersionInfoSize(fileToCheck.getAbsolutePath(), null);
      Pointer buffer = Kernel32.INSTANCE.LocalAlloc(WinBase.LMEM_ZEROINIT, infoSize);
  
      try {
  
          Version.INSTANCE.GetFileVersionInfo(fileToCheck.getAbsolutePath(), 0, infoSize, buffer);
          IntByReference outputSize = new IntByReference();
          PointerByReference pointer = new PointerByReference();
          Version.INSTANCE.VerQueryValue(buffer, "\\", pointer, outputSize);
          VerRsrc.VS_FIXEDFILEINFO fileInfoStructure = new VerRsrc.VS_FIXEDFILEINFO(pointer.getValue());
  
          rtnData[0] = (short) (fileInfoStructure.dwFileVersionMS.longValue() &gt;&gt; 16);
          rtnData[1] = (short) (fileInfoStructure.dwFileVersionMS.longValue() &amp; 0xffff);
          rtnData[2] = (short) (fileInfoStructure.dwFileVersionLS.longValue() &gt;&gt; 16);
          rtnData[3] = (short) (fileInfoStructure.dwFileVersionLS.longValue() &amp; 0xffff);
  
          return String.format("%s.%s.%s.%s", rtnData[0], rtnData[1], rtnData[2], rtnData[3]);
  
      } catch (Exception exception) {
  
          return null;
  
      } finally {
          Kernel32.INSTANCE.GlobalFree(buffer);
      }
  }
  </code></pre>