当它应该在rt.jar中时,我为什么不拥有这个类? [英] Why don't I have this class when it is supposed to be in rt.jar?

查看:95
本文介绍了当它应该在rt.jar中时,我为什么不拥有这个类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在尝试在java中实现LDAP连接......这需要 com.sun.jndi.ldap.LdapCtxFactory 。 Jarfinder显示 LdapCtxFactory 应该包含在 rt.jar 中,据我所知这是java SDK的基础。 Eclipse无法找到它(我正在尝试导入它)。

So, I am trying to implement an LDAP connection in java...this requires the com.sun.jndi.ldap.LdapCtxFactory. Jarfinder shows that the LdapCtxFactory should be included in rt.jar, which to my understanding is the base of the java SDK. Eclipse can't find it (I'm trying to import it).

我遇到了类似于此前的问题,但我通过安装jar来解决它包含它........现在我非常困惑,因为它所包含的jar是默认的jar?

I was having an issue similar to this earlier, but I resolved it by installing the jar which contains it........now I'm super confused, since the jar it is contained in is the default jar?

注意这也是Android项目的一部分。会有所作为吗?

Note this also is a part of an Android Project. Would that make a difference?

编辑

我在哪里使用这个包如下:

Where I'm using this package is the following:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapHost);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, user + "@" + domain);
env.put(Context.SECURITY_CREDENTIALS, pass);

然后我使用哈希表创建Context:

And then later on I create the Context using the hash table:

ctxGC = new InitialLdapContext(env, null);

所以,因为我没有 com.sun ,我无法在哈希表中提供。我甚至需要第一线吗?我不完全确定它是什么...

So, since I don't have the com.sun, I can't provide that in the hash table. Do I even need that first line? I'm not entirely sure what it is for...

推荐答案

Android不包含来自JRE的Web Services API(即javax.naming)

Android does not include the Web Services API from the JRE (i.e. javax.naming)

然而,所有评论都非常有用且信息丰富,最终导致我找到了问题的核心。

However, all the comments were very useful and informative, and are what eventually led me to find the core of the problem.

我需要下载另一个库,即UnboundId库。

I needed to download another library, the UnboundId library.

http://www.unboundid.com/products/ldapsdk/

这篇关于当它应该在rt.jar中时,我为什么不拥有这个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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