Reliable approach for loading resources in Java / JNLP -


I am writing a Java application that requires access to many resources in a .jar file running on JNLP.

While the application works well in my development environment (Eclipse), when it is executed through JNLP, apparently because it can not find the resource file in the jar. I have checked the resource file and the resources are definitely there.

I am currently using the code:

  someclass.getResourceAsStream ("/ resources / somefile png");  

Will work with JNLP. What is the correct way to access a resource file in JR?

Use: this.getClass (). GetClassLoader (). GetResourceAsStream (name) example: myClass.getClass () GetClassLoader (). GetResourceAsStream ("resource / somefile.png")

Two tips: 1 - Use your own class in the jar file. If any other class is used - for example the object - fails - 2 - the name i.e. Resource without '/'


Comments