如何更改java DNS服务提供商 [英] How to change the java DNS service provider

查看:287
本文介绍了如何更改java DNS服务提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个快速的网络爬虫,我需要多线程的DNS解析,所以我选了一个叫做 dnsjava的多线程DNS服务提供商。不幸的是,我不知道如何更换默认的DNS服务提供商。



我浏览了 README 文件为dnsjava,但说明并不是很好。


更换标准的Java DNS
功能:



从Java 1.4开始,服务
提供程序可以在运行时加载。
要加载dnsjava服务提供程序,
如上所述构建它,并设置
系统属性:



sun.net.spi .nameservice.provider.1 = dns,dnsjava



这指示JVM以
最高优先级为DNS使用
dnsjava服务。


有几件事我不清楚:


  1. 我在哪里放置dnsjava.jar?

  2. 系统属性应该在哪里设置(是程序设计还是某种类型的文件更改)?

我在Windows 7机器上运行,我不知道我需要做什么来查找/修改系统属性...帮助!



更新:

得到: System.setProperty sun.net.spi.nameservice.provider.1,dns,dnsjava);

解决方案

一个狂野的猜测。


  1. 将dnsjava.jar文件放在应用程序的类路径中。

  2. 在您的应用程序启动主方法之前设置系统属性。


I'm building a fast web crawler and I need to have multithreaded DNS resolution, so I picked up a multithreaded DNS service provider called dnsjava. Unfortunately, I can't figure out how to replace the default DNS Service Provider.

I went over the README file for dnsjava, but the instructions are not very through.

Replacing the standard Java DNS functionality:

Beginning with Java 1.4, service providers can be loaded at runtime. To load the dnsjava service provider, build it as explained above and set the system property:

sun.net.spi.nameservice.provider.1=dns,dnsjava

This instructs the JVM to use the dnsjava service provide for DNS at the highest priority.

There are a couple of things that I'm unclear on:

  1. Where do I place the dnsjava.jar?
  2. Where is the system property supposed to be set (is it programmatic or some type of file change)?

I'm running on a Windows 7 machine and I'm not sure what I need to do to find/modify the system properties... help!?

Update:
Got it: System.setProperty("sun.net.spi.nameservice.provider.1","dns,dnsjava");

解决方案

A wild guess.

  1. Put the dnsjava.jar file in the classpath of your application.
  2. Have the system property set before launching the main method in your application.

这篇关于如何更改java DNS服务提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆