Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding simple JNDI program  RSS feed

suresh sai
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.,

I have written a simple JNDI program in IBM RAD.While running its showing
"Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory " Exception. After that I have downloaded and included fscontext.jar in the libraries. But it`s showing another exception...

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jndi/toolkit/chars/CharacterEncoder

Here I am giving complete code.

package mypackage;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class NamingExample {

public static void main(String []l){
Hashtable environment=new Hashtable();
Context intialContext=new InitialContext(environment);
String name="D:\\sureshsai";
Object object=intialContext.lookup(name);
System.err.println("the name ... "+name+" is bound to "+object);
}catch (NamingException ne) {
System.err.println("naming exception was thrown... "+ne.getMessage());


Please help me to make the code runnable.
Chris Hurst
Ranch Hand
Posts: 443
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Are your jars on your classpath ?
2) then double check (unzip) that class in is the jars (it's meant to be).

Now possibly what is the problem ..

3) Check the class file (java) versions of the related classes eg if old java tries to link to new class files it'll say can't find the file when what it means is can't find a compatiable version so you need to check your Java version and the version of the class files in the two jars all are appropriate to work together ...

easiest way make sure the jars come from the same place and upgrade Java to the latest.

4) Failing that check they haven't done anything 'unique' in the MANIFEST.INF with regards to class paths etc etc
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!