JavaFX System.setProperty 管理员权限

标签 java security javafx jvm

我需要管理员权限才能在 JavaFX 中使用 System.setProperty() 方法吗?我真的很困惑阅读 documentation :

 @exception  SecurityException  if a security manager exists and its
     *             <code>checkPermission</code> method doesn't allow
     *             setting of the specified property.

什么情况下 JVM 不允许我设置属性?

如果我的应用程序是捆绑 JavaFX 应用程序,它是否有所不同? 谢谢。

最佳答案

安全管理器与通过“管理员访问权限”定义的操作系统权限无关。

安全管理器描述here 。特别注意:

A security manager is an object that defines a security policy for an application. This policy specifies actions that are unsafe or sensitive. Any actions not allowed by the security policy cause a SecurityException to be thrown.

Typically, a web applet runs with a security manager provided by the browser or Java Web Start plugin. Other kinds of applications normally run without a security manager, unless the application itself defines one. If no security manager is present, the application has no security policy and acts without restrictions.

因此,在 Web Start 下运行的应用程序将具有一个安全管理器,该管理器允许由 JNLP 文件配置的操作(并且仅允许对签名应用程序进行提升的操作)。

除非您竭尽全力改变这一点,否则作为“普通”桌面应用程序运行的独立应用程序将不会有安全管理器,并且其操作也不会受到限制。特别是,如果没有安全管理器,那么根据您引用的文档:

@exception  SecurityException  if a security manager exists and its
     *             <code>checkPermission</code> method doesn't allow
     *             setting of the specified property.

不会抛出SecurityException

关于JavaFX System.setProperty 管理员权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44134130/

相关文章:

java - 为什么这个 Java 计时器示例永远不会结束

css - 如何从 JavaFX 按钮中删除圆 Angular

multithreading - 为 javaFX 应用程序中的多个任务调用 Platform.runLater

ios - iOS App Store 现在支持动态下载代码。我该如何实现?

php - 在 PHP 中设置管理区域的最安全方法是什么?

java - 为什么 thread.sleep 会使我的 JavaFX 应用程序崩溃?

java - 使用 Spring MVC RequestMappingHandlerMapping 和 Spring Websocket 的 ServletWebSocketHandlerRegistry 处理相同的 URL

java - 为什么JVM中String对象和文字的内存空间是分开的?

java - 如何使 Java Swing 动画更流畅

security - 为什么采用哈希模的加盐哈希会导致非常不均匀的分布?