简体   繁体   English

如何提示用户授予我的程序读/写权限

[英]How can I prompt users to grant read/write permission to my program

I've made a lovely computer program in Java, equipped with handy jpackage installers, and I would love to share it with all of the world in a user-friendly manner.我在 Java 中制作了一个可爱的计算机程序,配备了方便jpackage安装程序,我很乐意以用户友好的方式与全世界分享它。 As part of its design, my program writes the user's custom settings to a file in the installation directory using an ObjectOutputStream .作为其设计的一部分,我的程序使用ObjectOutputStream将用户的自定义设置写入安装目录中的文件。 Unfortunately the program lacks permission to read and write files in secure folders such as "Program Files".不幸的是,该程序缺乏在“程序文件”等安全文件夹中读取和写入文件的权限。

I can't expect average users to know how to set up a policy file, so is there some way I can automate this process or prompt the user to grant read/write permissions during installation without paying hundreds of dollars to a Code Certifying Authority?我不能指望普通用户知道如何设置策略文件,那么有什么方法可以使这个过程自动化或提示用户在安装过程中授予读/写权限,而无需向代码认证机构支付数百美元? Or should I continue what I'm already doing which is asking users to install the software to their home directory or run the program as administrator?或者我应该继续我已经在做的事情,即要求用户将软件安装到他们的主目录或以管理员身份运行程序? What do other programmers do in this type of situation?其他程序员在这种情况下会做什么?

You can use local application data directory for these kind of files.您可以将本地应用程序数据目录用于此类文件。 See What is the cross-platform way of obtaining the path to the local application data directory?请参阅获取本地应用程序数据目录路径的跨平台方式是什么? for details详情

You shouldn't write to files to save user settings.您不应该写入文件来保存用户设置。

Java have a much better way of saving settings with Preferences: https://docs.oracle.com/javase/8/docs/api/java/util/prefs/Preferences.html Java have a much better way of saving settings with Preferences: https://docs.oracle.com/javase/8/docs/api/java/util/prefs/Preferences.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何授予我的小程序权限 - how to grant permission to my applet 如何使用java程序向Windows机器的所有用户授予对文件夹的完全权限? - How to grant full permission to a folder to all users of a windows machine using java program? 如何使我的程序写在另一个程序中? - How can i make my program write in another program? 如何在安全管理器策略文件中为可变父目录授予文件读/写权限 - How to grant file read/write permission in a Security Manager policy file for variable parent directories 如何在程序中输出用户选择的选择选项? - How can I output a chosen option of the users choice in my program? 如何授予applet读取系统属性的权限? - How to grant applet permission to read system properties? 如何将命令提示符中的变量传递到我的 java 程序中 - How can I pass variables from the command prompt into my java program 为什么可以在命令提示符下设置路径,但不能在程序中设置路径? - Why can I set a path in the command prompt but not my program? 如何在我的 android 应用程序中根据请求自动授予 SYSTEM_ALERT_WINDOW 权限? - How do I grant SYSTEM_ALERT_WINDOW permission automatically on request, in my android App? 如何从Python程序创建的文件中读取Java程序中的RDD - How can I read RDD in my java program from a file that was created by Python program
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM