I need to package a configuration file within a jar. the configuration file is under the root of the jar file. However I got the following error:
Cau
The file should be in the same package as the MyClass. I just realized you are creating a File object. Instead try using getResourceAsStream(). This is the right way if you want to read the contents from a classpath resource. Here is the example.