Writing to C: \ Program Files from a Java Program

I wrote a Java application that includes self-learning. Self updater downloads new versions of programs from a web server and replaces application files. Although this works fine if the application is installed, for example. in the users home directory it does not work on Windows machines if it is installed in the C: \ Program Files folder. This is due to the fact that the JVM runs under a user account that does not have write access to the program directory. If the source program, for example. the installer, trying to write to the program folder, usually a pop-up window appears asking you to allow the write operation. This does not happen for Java applications. Why?

Is there a way to achieve that writing a Java program to a restricted folder triggers a security popup so that the user can allow access to this folder?


Thank you for your responses. According to the answers, I see the following options:

  • Java Web Start
    For me, this is not an option for end users. I think that no one can expect from a regular end-user to know what Java Web Start is, what is good and how to use it, for example, I doubt that a regular Windows user knows how to uninstall a Java Web Start application.

  • Use an exe-launcher with a manifest to launch a Java application.
    As far as I understand this solution, exe-launcher would request extended execution right when the application starts. This is not exactly what I want, because for my use case it would be enough to get extended rights if an update is available, and not every time the application starts.

  • Perform the update operation by calling your own executable file.
    You can call your own executable file so that it can perform the update operation. Thus, the application will only request extended rights if an update is available. This sounds good, but includes some native encodings for Windows and does not work on other platforms.


  • , , . . InnoSetup Windows, , , , .


  • , . .

+4
2

, , . , , , .

Java-, , . "", , .

+2

inno setup , .

, AppName/data​​p >

[Dirs]
Name: "{app}"; 
Name: "{app}\data"; Permissions: everyone-full

[Files]
Source: data\*; DestDir: {app}\data\; Flags: ignoreversion recursesubdirs createallsubdirs; Permissions: everyone-full
+3

All Articles