Hi!All
What value should i pass to Context.PROVIDER_URL, when Setting up environment for creating the initial context?
I'm trying to bind and then lookup valid file object in JNDI using the following method and code.Im using j2sdk1.4.Im running my JNDI client as a standlone
java class and not using
ant App server. I have placed jndi.jar,fscontext.jar,providerutil.jar in <J2SDK_HOME>\jre\lib\ext folder
Here's the code
public static void main(
String[] args)//throws FileNotFoundException
{
File file;
file=new File("C:\\work_dir\\helloworld.txt");
System.out .println("filename" +""+ file.getName());
System.out.println(file);
try
{
if(file.exists())//throw new FileNotFoundException();
System.out.println("file found");
else
System.out.println("file not present");
}
catch(Exception fe)
{
System.out.println(fe);
}
// Set up environment for creating the initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL," ");//what value to give??
try {
// Create the initial context
Context ctx = new InitialContext(env);
//bind the object
ctx.bind("myfile",file);
// Look up an object
File fileobj = (File)ctx.lookup("myfile");
System.out.println(fileobj);
//close the context
ctx.close();
}
catch (NamingException e)
{
System.err.println("Problem looking up " + ": " + e);
}
}
}
Thanx in advance for any kind of help.
Regards
ved