Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6223225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:27:05+00:00 2026-05-24T08:27:05+00:00

Does anybody know how got get the version info for a executable/file via Java.

  • 0

Does anybody know how got get the version info for a executable/file via Java. The scenario is that I have a file on my local system and if the version on the server is newer then the one on my system I need to download the file from the server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:27:07+00:00Added an answer on May 24, 2026 at 8:27 am

    After spending hours online and coding I found a solution using JNA to get the Version Information for a file.

    import com.sun.jna.Library;
    import com.sun.jna.Memory;
    import com.sun.jna.Native;
    import com.sun.jna.Pointer;
    import com.sun.jna.ptr.IntByReference;
    import com.sun.jna.ptr.PointerByReference;
    import com.sun.jna.win32.W32APIOptions;
    import java.io.IOException;
    
    
    public class FileVersionInfo
    {
        interface Version extends Library {
    
            Version INSTANCE = (Version) Native.loadLibrary("Version", Version.class, W32APIOptions.UNICODE_OPTIONS);
    
            public int GetFileVersionInfoSizeW(String lptstrFilename, int dwDummy);
    
            public boolean GetFileVersionInfoW(String lptstrFilename, int dwHandle,
                int dwLen, Pointer lpData);
    
            public int VerQueryValueW(Pointer pBlock, String lpSubBlock,
                PointerByReference lplpBuffer, IntByReference puLen);
    
        }
    
        static class VS_FIXEDFILEINFO extends com.sun.jna.Structure {
            public int dwSignature;
            public int dwStrucVersion;
            public int dwFileVersionMS;
            public int dwFileVersionLS;
            public int dwProductVersionMS;
            public int dwProductVersionLS;
            public int dwFileFlagsMask;
            public int dwFileFlags;
            public int dwFileOS;
            public int dwFileType;
            public int dwFileSubtype;
            public int dwFileDateMS;
            public int dwFileDateLS;
    
               public VS_FIXEDFILEINFO(com.sun.jna.Pointer p){
                    super(p);
               }
        }
        public static void main(String[] args) throws IOException {
    
            int dwDummy = 0;
            int versionlength = Version.INSTANCE.GetFileVersionInfoSizeW(
                    "C:\\Test\\chromeinstall.exe", dwDummy);
    
            byte[] bufferarray = new byte[versionlength];
            Pointer lpData = new Memory(bufferarray.length);    
    
            PointerByReference lplpBuffer = new PointerByReference();
            IntByReference puLen = new IntByReference();
            boolean FileInfoResult = Version.INSTANCE.GetFileVersionInfoW(
                    "C:\\Test\\chromeinstall.exe",
                    0, versionlength, lpData);
            System.out.println(FileInfoResult);
            int verQueryVal = Version.INSTANCE.VerQueryValueW(lpData,
                    "\\", lplpBuffer,
                    puLen);
    
            VS_FIXEDFILEINFO lplpBufStructure = new VS_FIXEDFILEINFO(
                    lplpBuffer.getValue());
            lplpBufStructure.read();
    
            short[] rtnData = new short[4];
            rtnData[0] = (short) (lplpBufStructure.dwFileVersionMS >> 16);
            rtnData[1] = (short) (lplpBufStructure.dwFileVersionMS & 0xffff);
            rtnData[2] = (short) (lplpBufStructure.dwFileVersionLS >> 16);
            rtnData[3] = (short) (lplpBufStructure.dwFileVersionLS & 0xffff);
    
            for (int i = 0; i < rtnData.length; i++) {
                System.out.println(rtnData[i]);
            }
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know how to get thumbnail (still image) from 3gb video file? First
Does anybody know any good resources for learning how to program CIL with in-depth
Does anybody know a technique to discover memory leaks caused by smart pointers? I
Does anybody know of any sample databases I could download, preferably in CSV or
Does anybody know of a way to list up the loaded plugins in Vim
Does anybody know the logic behind making DataSourceSelectArguments sealed? I've implemented a custom DataSource
Does anybody know a good tutorial about Squid plug-in development?
Does anybody know of a method for creating custom Performance Counters using ordinary unmanaged
Does anybody know what hypothetical indexes are used for in sql server 2000? I
Does anybody know of an up to date tutorial on using Ajax with ASP.net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.