I have created a Java application that loads some configurations from a file conf.properties
which is placed in src/
folder.
When I run this application on Windows, it works perfectly. However when I try to run it on Linux, it throws this error:
java.io.FileNotFoundException: src/conf.properties (No such file or directory)
check your slashes and colons in my case i set my PS1 to following value
PS1='\n[\e[1;32m]$SYSNAME(\u)@[\e[1;33m]\w [\e[1;36m](\d \T) [!]\e[0m]\n\$ '
i am trying to read from the env .such as system.getenv
Java was throwing exception
java.lang.IllegalArgumentException: Malformed \uxxxx encoding
What you want to do is check out
System.getProperties()
and look forfile.separator
. The staticFile.pathSeprator
will also get you there.This will allow you to build a path that is native for whatever system you're running on.
(If indeed that is the problem. Sometimes I like to get the current directory just to make sure the directory I think I'm running in is the directory I'm really running in.)
Try the double slash, after doing things in JBoss I often had to refactor my code to use the double slashes
Instead of
use
Check the API for more detail: http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html
If you've packaged your application to a jar file, which in turn contains the properties file, you should use the method below. This is the standard way when distributing Java-programs.
The / in the path points to the root directory in the jar file.
You should check the working directory of your application. Perhaps it is not the one you assume and that's why 'src' directory is not present.
An easy check for this is to try the absolute path (only for debugging!).