Nifty Basics

I’ve been trying to follow the example at

I have copy+pasted code directly from it, and it still does not work for me.

niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();

try {
} catch (Exception e) {

nifty.fromXml("niftyGUI/NiftyGUI.xml", "start", screenController);


<?xml version="1.0" encoding="UTF-8"?>

The error I get is

org.xml.sax.SAXParseException; cvc-elt.1: Cannot find the declaration of element 'nifty'

Changing nifty.validateXml("niftyGUI/NiftyGUI.xml"); to a different file address gives a different error, so it IS finding the file correctly.

I have also looked at several forum links which did not help me, such as

What am I doing wrong?

The XML didn’t post right, so I put it on pastebin.

You’re missing the schema declarations on the nifty-tag:

[xml]<nifty xmlns=“” xmlns:xsi=“


Without those an xml validator wouldn’t know where to find the “rules” for how the xml file should be structured.

Edit: Ignore the -tags, they seem to be automatic even inside [xml][/xml]-tags.

That worked, thanks. In case anyone else was having the same problem, the updated xml file is at

Does this mean that I have to be able to connect to the internet to start my program? What if I want it to work offline?

There should be an xsd-file in the nifty source as well and you can use that one instead, offline, if you like.

Of course you should then point your xml-file to that xsd-file instead of to the online URL.

There’s no need to validate the xml file to run nifty though, it’s just to make sure it’s correctly formatted.

Here’s some info on xml schemas (xsd’s):