简体   繁体   English

在Java中设置系统范围/全局代理

[英]Setting system-wide/global proxy in java

I am currently working on a local proxyserver in Java, now to prevent any work for the user I want to set the system-wide proxy settings to the local proxy server using my code. 我目前正在Java中使用本地代理服务器,现在是为了防止用户想要使用我的代码将系统范围的代理设置设置为本地代理服务器。

I tried using; 我尝试使用;

System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "10001");

System.setProperty("proxySet", "true");

But if I am correct these are just the settings for the JVM? 但是,如果我正确的话,这些仅仅是JVM的设置吗?

How can I achieve setting a system-wide proxy? 如何实现设置系统范围的代理?

The solution was different for each platform, I currently only implemented the proxy settings on Windows and OSX. 每个平台的解决方案都不相同,我目前仅在Windows和OSX上实现了代理设置。

  • Modify the preferences.plist file on OSX, this is the file located at 修改OSX上的preferences.plist文件,该文件位于

/Library/Preferences/SystemConfiguration/preferences.plist /Library/Preferences/SystemConfiguration/preferences.plist

  • Modify the registry on Windows, editing the following path 在Windows上修改注册表,编辑以下路径

Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings 软件\\ Microsoft \\ Windows \\ CurrentVersion \\ Internet设置

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM