Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 8 to Java 11: package com.sun.jndi.ldap is not visible

After moving from Java8 to Java11, I'm getting the error "package com.sun.jndi.ldap is not visible". But I need this package for the Class LdapCtxFactory. Is the package moved or should I use another Class for my Ldap-Connection?

Best regards

like image 485
JavaTourist Avatar asked May 06 '26 04:05

JavaTourist


1 Answers

Since your only use of the class LdapCtxFactory is a configuration setup as

env.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getName());

you can remove the dependency to the class by replacing LdapCtxFactory.class.getName() with the qualified name "com.sun.jndi.ldap.LdapCtxFactory", i.e.

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
like image 191
Holger Avatar answered May 08 '26 03:05

Holger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!