为什么我没有这个类

为什么我没有这个类

本文介绍了当它应该在 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);

然后我使用哈希表创建上下文:

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 服务 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 中时,为什么我没有这个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 07:25