Locating resources in Nifty

Quick question I was creating a quick nifty menu viewer for one of my colleagues so that he can use without the platform; however, I can’t get the menu’s to load properly its locating the xml files properly but neither does the main menu that works in another project nor the the preMade menus in the nifty jar file works properly. The only Time it works correctly is when their are no references to outside files.

btw i’m searching outside the assets folder, I believe this to be the issue but registering the below did not work are their any advice for the issue?


//TEMP IS THE altered path of the file where nifty finds the XML file

int r = temp.lastIndexOf("");

this.getAssetManager().locateAsset(new com.jme3.asset.AssetKey<Object>(temp.substring(0, r)));


Everything is loaded from the assetmanager so you have to register locators for all paths you want to load from that are not in the classpath.

ahh it was registerLocator method not locateAsset i slightly remember somewhat…Is the search recursive or it only applies to that folder because i’m still unable to locate them

thnx for the quick response

There is no search, otherwise all images with the same name would be the same, you specify a root path and have your assets in sub-paths.

hmm okay; however, i still can’t get it to work correctly. Their is no dedicated assets folder since the xml files i’m accessing is external. I simply extracted the test folders from the nifty jar and put it next to the webstart application or in a random place in the project folder. The nifty xml files are found and loaded correctly its just its assets

i’ve tried various combinations first altering the path of the xml file and now with whats below for the file path of the executing class


getAssetManager().registerLoader(AWTLoader.class.getName(), “png”);

getAssetManager().registerLoader(WAVLoader.class.getName(), “wav”);

getAssetManager().registerLocator("/", ClasspathLocator.class.getName());

getAssetManager().registerLocator("…/", ClasspathLocator.class.getName());

getAssetManager().registerLocator("…/…/", ClasspathLocator.class.getName());


ohh okay its understood i guess when i deploy i would search the root folder however before that I placed the nifty examples back into the assets folder and deleted my custom menu since i made controls for it instead of using what was their however I’m getting the same error with being unable to locate resources…whats odd though is that i checked the custom menu before i deleted it and it loads (though since i made separate controls for it in another project thats all it does)

This is totally messed up, notice that the assets inside the nifty files also have paths, its like a classpath, some folder has to be the root folder.