 <p>Unlike what everyone else tells you, this is unrelated to Windows and <code>File.separator</code>.</p> <p><code>String DIR_PATH = "a/b/c/"</code> is just a String, neither Java nor the compiler make any attempt to understand what it could mean, so you get the same value both on Windows and Linux.</p> <p>Also note that <code>/</code> works as a file separator both on Unix and Windows, so this isn't an issue either. When necessary, Java will convert <code>/</code> to <code>\</code>.</p> <p><code>File DIR_FILE = new File(DIR_PATH);</code> is a constant but <code>new File()</code> is still executed by the VM at runtime when the class is loaded. So the path is <strong>not</strong> converted to Windows format while the <em>compiler</em> generates byte code.</p> <p>So the problem you describe must be elsewhere or an important part of the code example you posted was changed when you simplified it for the question. My guess is that someone put a Windows-style path into the code elsewhere or maybe the config and you overlooked this.</p> <p>That said, a safe way to build paths is to use <code>File(File, String)</code>:</p> <pre><code>File DIR_PATH = new File( "a", new File( "b", "c" ) ); </code></pre> <p>This will always build a path that works, no matter what the file separator is. If you must, you can use</p> <pre><code>File DIR_PATH = "a" + File.separator + "b" + File.separator + "c"; </code></pre> <p>but that can fail for more complex examples and it's more text to read.</p>