How can I specify drive letter (windows) for PROVIDER_URL JNDI source code

I am using com.sun.jndi.fscontext.RefFSContextFactoryfactory based JNDI context . It seems to be taking the drive where the java application is running.

Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,"file:///tmp/jms/mycontext");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new InitialContext(properties);

How can I specify a drive letter, for example d:/tmp/jms/mycontext? Usage file://d:/tmp/jms/mycontextseems to still go to drive c on my system

+3
source share
2 answers

After some troubleshooting and debugging, I figured this out. Using extra \ before the drive letter resolves it

properties.put(Context.PROVIDER_URL,"file://\\d:\\tmp\\mycontext");
+1
source

Same:

"file:D:\\tmp\\jms\\mycontext"

developerWorks , :
IBM WebSphere Developer: Java WebSphere MQ V6.0

0

Source: https://habr.com/ru/post/1764228/


All Articles