开发者

How can I specifiy the drive letter (windows) for the PROVIDER_URL of the JNDI InitialContext

开发者 https://www.devze.com 2023-01-15 10:59 出处:网络
I am using the com.sun.jndi.fscontext.RefFSContextFactory file based JNDI context factory. It seems to take the drive of the where the java application is started in.

I am using the com.sun.jndi.fscontext.RefFSContextFactory file based JNDI context factory. It seems to take the drive of the where the java application is started in.

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 =开发者_StackOverflow社区 new InitialContext(properties);

How can I specify the drive letter such as d:/tmp/jms/mycontext ? Using file://d:/tmp/jms/mycontext seems to still go to the c drive on my system


After some troubleshooting and debugging myself I figured it out. Using an extra \ before the drive letter solves it

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


Like so:

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

There are some examples in a tutorial at developerWorks that may be useful:
IBM WebSphere Developer Technical Journal: Running a standalone Java application on WebSphere MQ V6.0


"file:///D:/temp" worked for me

0

精彩评论

暂无评论...
验证码 换一张
取 消