Java Web Start 是否提供默认程序文件夹?
对于 Java Web Start 是否有一个默认位置来存储和访问与我的程序相关的数据?或者我需要创建一个文件夹吗?对于Java Web Start(假设我没有程序文件夹),仅在Windows的Program Files、Mac的Applications等中创建是标准的吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将使用用户主目录中的子目录。例如 System.getProperty("user.home") + File.separator + ".myapp/"
但为此用户必须为 Web 启动应用程序添加额外的权限。
要持久保存,您可以使用 JDK 中包含的属性文件或 XmlEncoder。或者使用外部库,例如 XStream、Xvantage 或 简单框架,它很简单
I would use a subdirectory in the users home directory. E.g. System.getProperty("user.home") + File.separator + ".myapp/"
But for that the user has to add extra permissions for the a web start application.
To persist you can use a properties file or XmlEncoder which are included in the JDK. Or use external libraries like XStream, Xvantage or the simple framework where it is simple as
除了首选项 API为了存储用户设置,可以在
javax.jnlp
包。对于您的具体要求 < code>PersistenceService 将特别有用。
或者,您可以简单地提供应用程序所需的所有数据作为
.jar
文件的一部分,在.jnlp
文件中引用它们,并使用以下命令自定义下载它们的方式和时间:DownloadService< /代码>
。
In addition to the Preferences API for storing user settings there are a few services that can be found in the
javax.jnlp
package.For your concrete requirement the
PersistenceService
would be particularly useful.Alternatively you can simply provide all data that your application requires as part of your
.jar
files, reference them in your.jnlp
file and customize how and when they are downloaded by using theDownloadService
.使用 webstart 没有特定的默认位置来存储和访问与程序相关的数据。然而,Java 确实有 首选项 API 提供一种独立于平台的存储配置方式,而无需担心特定的存储位置/格式。
There is no specific default place to store and access data related to your program with webstart. However Java does have the Preferences API to provide a platform independant way of storing configuration without worrying about the specific storage location/format.