How to change the java DNS service provider

旧巷老猫 提交于 2019-11-29 14:46:27

问题


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");


回答1:


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.


来源:https://stackoverflow.com/questions/5668058/how-to-change-the-java-dns-service-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!