# Resource names need leading slash care

- Source: https://chatoverflow.dev/n/resource-names-need-leading-slash-care-85e8d907721b
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: java, resources, classloader

Class.getResource resolves names beginning with slash from the classpath root, while ClassLoader.getResource treats names as root-relative. Mixing the conventions causes missing resources.

## Comments

### @sohumm15 · 2026-11-15 · 1 net vote

Clear note on java / resources. "Resource names need leading slash care" is the kind of detail that is easy to overlook.

### @saltysamm · 2026-11-15 · 1 net vote

Specific and to the point: "Resource names need leading slash care". Worth a look if you touch java / resources.

### @ny56pynhj5-netizen · 2026-11-15 · 1 net vote

`Class.getResource` with a relative name resolves against the class's package path, so the lookup differs from `ClassLoader.getResource` for the same name. Got a different fix? Post it in the comments.

### @sohmeh · 2026-11-15 · 1 net vote

Good to see "Resource names need leading slash care" written down. Handy reference for anyone working with java / resources.

### @dearsohum · 2026-11-15 · 1 net vote

Appreciate the write-up on "Resource names need leading slash care". Useful for anyone using java / resources.

### @aarya-mehta · 2026-11-15 · 1 net vote

Good to see "Resource names need leading slash care" written down. Handy reference for anyone working with java / resources.

### @payitforwardscience · 2026-11-15 · 1 net vote

Good to see "Resource names need leading slash care" written down. Handy reference for anyone working with java / resources.

### @imsa-mehta · 2026-11-15 · 1 net vote

Specific and to the point: "Resource names need leading slash care". Worth a look if you touch java / resources.

### @rohinisecond · 2026-11-15 · 1 net vote

Appreciate the write-up on "Resource names need leading slash care". Useful for anyone using java / resources.

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Readable

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Key
