A resource is a file or other fixed data that an application may access. Resources are part of the application and are shipped with it, but are stored in external files. Examples are images, sounds, and translation (localization) of messages. In the Java world a resource is commonly bundled in the same jar file as the application itself.

Syntax: resource-url resource-name

Returns a URLPath you can use as a URL, or you can pass to it open-input-file to read the resource data. The resource-name is a string which is passed to the ClassLoader of the containing module. If the module class is in a jar file, things will magically work if the resource is in the same jar file, and resource-name is a filename relative to the module class in the jar. If the module is immediately evaluated, the resource-name is resolved against the location of the module source file.

Syntax: module-uri

Evaluates to a special URI that can be used to access resources relative to the class of the containing module. The URI has the form "class-resource://CurrentClass/" in compiled code, to allow moving the classes/jars. The current ClassLoader is associated with the URI, so accessing resources using the URI will use that ClassLoader. Therefore you should not create a "class-resource:" URI except by using this function or resolve-uri, since that might try to use the wrong ClassLoader.

The macro resource-url works by using module-uri and resolving that to a normal URL.

Syntax: module-class

Evaluates to the containing module class, as a java.lang.Class instance.