I'm creating a Jar file which automatically creates a target folder.
Within the the target folder I have an XSD file. When I execute the jar file via the command prompt - it is looking for the file in the target folder as opposed to the test-classes folder.
Is there anyway I can configure this so that the compiler looks at the test-classes folder for the file?
Thanks
The "test-classes folder" is just a random place on your hard disk.
Java supports 3 generic places to look for resources:
the current working directory . this is where your command prompt is.
the user home This is what you get when calling System.getProperty("user.home")
. On Unix this resoves to $HOME
and on Windows to %USERPROFILE%
the own code location . Resources in the same package as your class are accessed with getClass().getResource("filenameWithoutPath")
But usually you place resources in a special folder in the application root and access it like this: getClass().getResource("/relative/path/from/src/root/filenameWithoutPath")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.