Java Learning Series: The program sets environment variables, and then visits the specified website information

Scenes

Sometimes, in the actual development, sometimes it is necessary to access certain pages through network settings. However, some software will not forward all requests, but will only forward requests that pass through the corresponding port. Then, if the program does not do processing, there is no way to access the page through the software. This blog mainly explains and solves this situation.

surroundings

software version
JDK 1.8

text

At the beginning of the program, add the following code, mainly about the ip and port of vpn

System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "7890");
System.setProperty("https.proxySet", "true");
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("https.proxyPort", "7890");
System.setProperty("socket.proxySet", "true");
System.setProperty("socket.proxyHost", "127.0.0.1");
System.setProperty("socket.proxyPort", "7890");

I looked it up on the Internet before, and basically there is only HTTP configuration, but now many applications are already HTTPS . Therefore, the configuration must be complete to take effect.

to sum up

By setting environment variables, you can visit the corresponding website through the network software.

Ask for praise

If my article is helpful to everyone, you can click like or favorite at the bottom of the article;
if there is a good discussion, you can leave a message;
if you want to continue to view my future articles, you can click Follow
You can scan the following QR code to follow me 'S public account: Fengye Zhixuege, check out my latest share!
Insert picture description here
Bye bye

Guess you like

Origin blog.csdn.net/u013084266/article/details/109024633