code: public static String[] getByJNDI() {
          try {
              Class<?> dirContext =
                      Class.forName("javax.naming.directory.DirContext");
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
              Class<?> initialDirContext =
                      Class.forName("javax.naming.directory.InitialDirContext");
              Constructor<?> constructor = initialDirContext.getConstructor(Hashtable.class);
  
              Object obj = constructor.newInstance(env);
              Method m = dirContext.getMethod("getEnvironment");
              Hashtable newEnv = (Hashtable) m.invoke(obj);
              String dns = (String) newEnv.get("java.naming.provider.url");
              String dnsTrim = dns.replace("dns://", "");
              return dnsTrim.split(" ");
          } catch (Exception e) {
              e.printStackTrace();
          }
          return null;
      }
docs: has 300s latency when system resolv change https://community.oracle.com/thread/1148912