Search code examples
javawindowsdllwindows-10jna

Java program w/JNA+DLL requires "Run as Administrator" under C:\Program Files on Win10?


I have a Java 8 program which runs fine everywhere on my Windows 10 computer except when run from under C:\Program Files or C:\Program Files (x86) where it requires to be "Run as Adminstrator" to work.

What are the limitations for running Java programs and accessing hardware from C:\Program Files ?

This Java program uses JNA to load a DLL and JavaFX to display a UI, so possibly that is related. A companion program in the same directory using on JavaFX but NOT JNA and DLLs works fine everywhere.

This is not an installer issue as an installer is not involved; the behavior does not change when an installer is used.

It is not an issue with embedded paths or with the (x86) and/or spaces in the path, as similar named directories to C:\Program Files (x86) also work fine.


Solution

  • I do not believe that the issue is Java-related, it is more about OS security model. Note that you can't save file directly to both of these folders, for example, but can copy any file to that folder using elevated prompt. That is a good security practice, and in a past it could be turned off (as far as i remember) by turning off the UAC (which was not recommended, anyway).

    If you want to update your application on a future then place it somewhere in different place as many apps doing.