I use GetModuleFileName method to get the current working directory, it's supposed to get the directory where the java class is(a) No it isn't. GetModuleFileName() isn't supposed to do either of those things. It is a Windows API that does something quite different. Look it up. While you're looking up the Windows API, find the one that gives you the current directory.