I am trying to create a simple http server.
But I have a little problem.
If my /www dir is in a .jar file compilation, all workse perfect: code:
private static final String DEFAULT_FILES_DIR = "/www"; .... private String getURLFromHeader(String header) { //gettint url from header .... return DEFAULT_FILES_DIR + url; } .... System.out.println("Resources: " + url + "\n"); System.out.println("Result code: " + code + "\n");
for index.html I become: Resources: /www/index.html Result code: 200 β everything works.
But when I do this:
private static final String DEFAULT_FILES_DIR = "D:/.../.../.../www";
the server says: "No one, I donβt know what you will do from me!" equals sign and enter: Resources: D:/.../.../.../www/index.html Result code: 404 β the file was not found.
What could it be?
Ps I tried to set a private static final String DEFAULT_FILES_DIR = "D:\\...\\...\\...\\www"; but that wouldnβt work!))))
java file jar resources
Andrew Evt
source share