3

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 = 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

mrjohn
  • 1,141
  • 2
  • 13
  • 21

3 Answers3

1

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");
mrjohn
  • 1,141
  • 2
  • 13
  • 21
0

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

T.Rob
  • 31,522
  • 9
  • 59
  • 103
  • actually that does not work as file://d:/tmp/jms/mycontext or file:D:\\tmp\\jms\\mycontext still goes to the drive that is used to start java and if java is started from C: it looks for c:/tmp/jms/context – mrjohn Sep 10 '10 at 21:19
  • 1
    Sorry to hear that. It works perfectly for me. I'm using IBM's Java 6.0 implementation though. – T.Rob Sep 11 '10 at 04:03
  • You could be right it depends on the java implementation. Didn't work for me with java 5 and eclipse as my development environment – mrjohn Sep 17 '10 at 20:21
0

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

bczoma
  • 181
  • 2
  • 10