Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a 32 bit window machine with a 32 bit JVM. I am trying to load a DLL file on the machine and the path specified contains '\' as path separator. However if I try to '/' as path separator in Java program it is not able to load the dll with the error message as 'File could not be found'.

However when I try to load the same DLL on a 64 bit windows machine with a 32 bit JVM, my Java program accepts '/' as a path separator. With '\' as path seperator in Java program it is not able to load the dll with the error message as 'File could not be found'.

Any pointers.

share|improve this question
It's your program, right? Code it to accept whatever you want it to accept. – David Schwartz May 22 '12 at 15:25
This probably has to do with the API you're using. You should post your code, and ask on Stack Overflow since this is a programming question. – Gilles Jun 25 '12 at 10:16

Windows uses backslashes for it's paths, it will never accept / forward slashes as a directory path.

In Java they can program it to accept what ever they want, they could have exclamation marks instead of back slashes if they chose to do so. So if back slashes aren't working, your software is faulty.

If you're programming this yourself in Java, you need to use the \\ escape character to represent a normal single \ backslash.

Let me know if I've totally misunderstood the question.

share|improve this answer
Actually, Windows is perfectly happy with slashes (/). In fact, the first version of MS-DOS with support for directories was happy with slashes (2.0). Most Windows programs tend to prefer backslashes but the Windows API functions will accept slashes and even a mix of both. Whether the JVM tries to interpret slashes and backslashes in some special way is another matter. – Bob May 22 '12 at 15:33
What @Bob said - try opening a command prompt, and typing >dir "c:/windows" – Geoff May 22 '12 at 16:01
Hi Amicable,Thanks for the response. I had the same understanding as you had but somehow the code behaves strangely. What I have used in the code is File.getAbsolutePath() which gives the full path followed by a file seperator followed by the dll file name. – user135605 May 22 '12 at 17:37
Hi Amicable, Thanks for your response. You have understood it correctly. My code uses File.getAbsolutePath() which returns the file path with '\' which is desirable and runs in windows 32 OS. However when I use the same thing in Windows 64 machine it does not work. The program runs fine if I replace '\' by '/'. Also I have used '\\' and not '\' else Java will give me compilation error. Thanks – user135605 May 22 '12 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .