There is a java program in the folder
I can compile it with javac testfile.java (while in that directory)
Resulting in testfile.class.
But I cannot run this file by typing java testfile
I'm afraid you've got it completely wrong. File objects don't depend on the classpath in any way. When you create a File object with a relative pathname, the path is relative to the current working directory (i.e., the "user.dir" system property). If you specify an absolute path, the file can be anywhere your app (or, more specifically, the user who's running ...