This problem might have been answered before but I can't seem to make it work. Tried several different previously asked questions and answers.
I have an XML schema file in resource package, and need to get it as a File object from another package called ui.
It must the problem with setting relative path here, but I can't figure out how to fix it.
Class pacakge: com/abc/ui/myClass.java
Resource package: com/abc/resources/schema/XMLSchema.xsd
Sample Code:
File schemaFile = null;
try {
schemaFile = new File(getClass().getClassLoader().getResource("../resources/schema/XMLSchema.xsd").getFile());
} catch (Exception e) {
e.printStackTrace();
}
and/or
File schemaFile = null;
try {
schemaFile = new File(getClass().getResource("../resources/schema/XMLSchema.xsd").getFile());
} catch (Exception e) {
e.printStackTrace();
}
No matter what I try, it keeps throwing null value.
Update:
Snap Shots:
Any solutions to this.