posted 7 years ago
Not if you need the resources to be on the classpath. If you want the resources to be in a separate folder within the JAR you can just add it directly, but then you won't be able to reach them using the getResource() and getResourceAsStream() methods, unless you prefix all the resource names with the name of the folder, which is bad form.
Let's say you have a class com.example.Hello, and you have a resource res/com/example/hello.txt. You can perform the following command:
This will create a JAR with the com/ folder at the top, and the res/ folder at the top. The problem with this approach is that to access the resource from your code, you have to call getResourceAsStream("/res/com/example/hello.txt") instead of the more sensible getResourceAsStream("hello.txt").