JM3: cannot locate resource… [Solved]

I have the problem of being unable to load a resource:





[java]Material mat = new Material(assetManager,

“H:/java/Workspace/DMF/assets/MatDefs/Misc/SolidColor.j3md”);[/java]



gives the error:



WARNUNG: Cannot locate resource: H:/java/Workspace/DMF/assets/MatDefs/Misc/SolidColor.j3md



Of course, the file is there and the capitalisation is correct. I also tried with relative path (“assets/MatDefs/Misc/SolidColor.j3md”), and with backslashes, but it still gives the same error.

Try this:

[java]assetManager.registerLocator(“H:/java/Workspace/DMF/assets/”,FileLocator.class);

Material mat = new Material(assetManager,“MatDefs/Misc/SolidColor.j3md”);

[/java]

or:

try to replace ‘/’ with double backslash , because the file-separator on Windows is a backslash

A, OK, working solution is…



[java]assetManager.registerLocator("H:/java/Workspace/DMF/assets/",FileLocator.class);

Material mat = new Material(assetManager, "MatDefs/Misc/SolidColor.j3md");[/java]



Thx, doe300…



BTW, windows ≥ 5.0 doesnt care if u use slash or backslash…

rhavin said:
BTW, windows ≥ 5.0 doesnt care if u use slash or backslash…

Wee, windows grows up xD
1 Like
normen said:
Wee, windows grows up xD

Mac fan boy spotted!! :D

@rhavin btw the SolidColor is deprecated, you should use the Unshaded.j3md instead. (in the same folder, and you can use the same parameters)

Hello!



What does using:



[java]assetManager.registerLocator(“H:/java/Workspace/DMF/assets/”,FileLocator.class);

Material mat = new Material(assetManager, “MatDefs/Misc/SolidColor.j3md”);[/java]



Really buy you? Does the locator specify an additional location where assets will be looked for when string file locations are spat at it? How flexible is it; like could I register this locator and just say “SolidColor.j3md” for example, and it would find it in the directories?



Just curious :smiley:

~FlaH

Well its all said in the hello assets tutorial really :stuck_out_tongue: You can even specify zip files in http locations this way, its very flexible.

Hello Again!



Doh. I must’ve skipped over that part when I did the tutorials months and months ago :stuck_out_tongue: derp derp. Or it wasn’t there then. Either way, I guess it was about time I fell prey to “Read the damn Manual!” :smiley:



Goes to show how far the documentation has come though. Rock on.



~FlaH