21xrx.com
2025-04-18 15:24:06 Friday
文章检索 我的文章 写文章
如何关闭Java自动更新
2023-06-11 03:50:56 深夜i     17     0
Java 更新

我非常讨厌Java的一种行为,那就是它总是充满着各种更新。每次更新时,我都需要停止我的工作并等待它完成,这极大的影响了我的效率。所以,我很高兴我找到了一个方法来关闭Java更新。

首先,我打开了控制面板并选择了Java。然后我点击了“更新”选项卡。在这里,我找到了“自动更新”选项,并将其从“自动检查更新”更改为“从不检查更新”。

这样一来,Java就不再检查和更新了。但是,如果您需要更新Java以解决某些安全性问题,请记住手动检查更新,以确保您的计算机获得最新的安全补丁。

以下是Java自动更新选项的代码示例:

public class JavaAutoUpdate {
  public static void main(String[] args) {
    // Get the current Java update settings
    String updateSetting = System.getProperty("java.util.prefs.SystemRoot") + "\\sun\\Java\\Deployment\\deployment.properties";
    Properties props = new Properties();
    try {
      props.load(new FileInputStream(updateSetting));
    } catch (IOException e) {
      e.printStackTrace();
    }
    String autoUpdate = props.getProperty("deployment.expiration.check.enabled");
    System.out.println("Current auto update setting: " + autoUpdate);
    
    // Disable Java auto updates
    props.setProperty("deployment.expiration.check.enabled", "false");
    try {
      OutputStream out = new FileOutputStream(updateSetting);
      props.store(out, "");
      out.flush();
      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    System.out.println("Java auto updates disabled.");
  }
}

其中,`deployment.expiration.check.enabled`属性用于控制Java自动更新。将其设置为`false`将禁用Java自动更新。

、代码示例、控制面板

  
  

评论区

请求出错了