When in java I use relative path to create file like this:
File file = new File("filename.txt");
How program resolve path? In my program I have an issue related to this. When I work I use eclipse - it run program from compiled files (without packing it to .jar). Ultimately the program will be runing as from jar file or by using some script in ubuntu. In all those 3 cases above code create path in different directory. To fix it I have to just understand how it works. So how do java resolve relative path like this?
It resolves it relative to your process's current working directory. For example, you can specify that in Eclipse in the run configuration.
Basically, you should either use an absolute filename, or make sure you're running it from an appropriate directory. (You haven't indicated how you're running it from a jar file or a script...)
See more on this question at Stackoverflow