I have a big issue doing something really stupid. That is to say open a stream to a resource file in my META-INF folder. I am working on a jar tool and on doing this:
InputStream schemaIS = this.getClass().getClassLoader().getResourceAsStream("/META-INF/schema.xsd");
I simply get a null! The project is built using maven and the xsd file ends up in the META-INF folder, but it still won't work.
What I don't understand is the theory behind it? How do the ClassLoader execute the lookup in the file system? How do I get my hands on the file?
You must open minecraft. jar in a program which can edit . zip files (such as 7-zip), then delete the META-INF folder as you would anything else. This should not require administrator privileges, as minecraft.
The META-INF folder is the home for the MANIFEST. MF file. This file contains meta data about the contents of the JAR. For example, there is an entry called Main-Class that specifies the name of the Java class with the static main() for executable JAR files. Follow this answer to receive notifications.
Jar files are used by all types of java applications, they have a specific structure - the META-INF folder contains the manifest information and other metadata about the java package carried by the jar file.
It shouldn't be at the project root, but directly under the source folder. At runtime, the persistence. xml file is searched in the classpath, under META-INF. So if you want the META-INF folder to be put at the top of the compiled package tree, you need to put it at the top of the source tree.
Try removing first slash:
InputStream schemaIS = this.getClass().getClassLoader().getResourceAsStream("META-INF/schema.xsd");
You need a leading slash if you are calling the getResourceAsStream
method on a Class
object. On a ClassLoader
object, the path is always absolute, and the leading slash is not necessary.
try this path: META-INF/schema.xsd
(first /
omitted)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With