Nifty 1.2 and Jme2 problem

ok, im new to nifty and xml… Im trying to do a basic example of nifty, but i cant even make it run because of an error



heres what it says

08 24, 10 10:32:39 PM class praktisan.TestNifty start()
SEVERE: Exception in game loop
java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParser
        at de.lessvoid.nifty.Nifty.initialize(Nifty.java:137)
        at de.lessvoid.nifty.Nifty.<init>(Nifty.java:111)
        at praktisan.TestNifty.simpleInitGame(TestNifty.java:35)
        at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
        at com.jme.app.BaseGame.start(BaseGame.java:74)
        at praktisan.TestNifty.main(TestNifty.java:30)
Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParser
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 6 more


heres my code

public class TestNifty extends SimpleGame {
   
    private Nifty nifty;

    public static void main(String[] args) {
        TestNifty app = new TestNifty();
        app.setConfigShowMode(ConfigShowMode.AlwaysShow);
        app.start();
    }

    protected void simpleInitGame() {

        nifty = new Nifty(new JmeRenderDevice(), new JmeSoundDevice(), new JmeInputSystem(), new TimeProvider());

        nifty.fromXml("nifty.xml", "myNiftyScreen");;
       
    }


    protected void simpleRender(float tpf) {
        nifty.render(true);
    }
}



please help me guys, dont have any idea what my error is and where should i start fixing it

Thank you

You have to add the xmlpull-xpp3-1.1.4c.jar (or similar) as well

Thank you!,

I  got it, the one in the http://www.xmlpull.org/v1/download/ didnt work for me.



Now i have resource locator problems  :D, gonna post it later if i couldnt solve it…

Im still having error, it is looking for my font file… i followed the instructions in this link and still didnt get it working.  Please help me. Im having the same error With or without the resource locators…



http://sourceforge.net/projects/nifty-gui/forums/forum/807893/topic/3800793



this is the error log

WARNING: Unable to locate: atomic.fnt
java.lang.NullPointerException
       at de.lessvoid.nifty.jme.render.JmeRenderFont.getTextureFile(JmeRenderFont.java:194)
       at de.lessvoid.nifty.jme.render.JmeRenderFont.<init>(JmeRenderFont.java:51)
       at de.lessvoid.nifty.jme.render.JmeRenderDevice.createFont(JmeRenderDevice.java:190)
       at de.lessvoid.nifty.render.NiftyRenderEngineImpl.createFont(NiftyRenderEngineImpl.java:151)
       at de.lessvoid.nifty.loaderv2.types.apply.Convert.font(Convert.java:35)
       at de.lessvoid.nifty.loaderv2.types.apply.ApplyRenderText.apply(ApplyRenderText.java:23)
       at de.lessvoid.nifty.loaderv2.types.apply.ApplyAttributes.applyRenderer(ApplyAttributes.java:81)
       at de.lessvoid.nifty.loaderv2.types.apply.ApplyAttributes.perform(ApplyAttributes.java:56)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyAttributes(ElementType.java:250)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:171)
       at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:143)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyChildren(ElementType.java:276)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:174)
       at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:143)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyChildren(ElementType.java:276)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:174)
       at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:143)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyChildren(ElementType.java:276)
       at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:174)
       at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:143)
       at de.lessvoid.nifty.loaderv2.types.ScreenType.create(ScreenType.java:75)
       at de.lessvoid.nifty.loaderv2.types.NiftyType.create(NiftyType.java:118)
       at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:406)
       at de.lessvoid.nifty.Nifty.fromXml(Nifty.java:307)
       at praktisan.TestNifty.simpleInitGame(TestNifty.java:48)
       at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
       at com.jme.app.BaseGame.start(BaseGame.java:74)
       at praktisan.TestNifty.main(TestNifty.java:34)
08 25, 10 2:23:48 AM de.lessvoid.nifty.Nifty gotoScreen
INFO: gotoScreen [myNiftyScreen]
08 25, 10 2:23:48 AM de.lessvoid.nifty.Nifty gotoScreenInternal
INFO: gotoScreenInternal [myNiftyScreen]
08 25, 10 2:23:48 AM de.lessvoid.nifty.Nifty gotoScreenInternal
WARNING: screen [myNiftyScreen] not found
08 25, 10 2:23:50 AM com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
AL lib: alSource.c:2361: alcDestroyContext(): deleting 64 Source(s)
08 25, 10 2:23:50 AM com.jme.app.BaseGame start
INFO: Application ending.


this, is my xml file, its is the same code in the nifty-tutorial.jnlp

<?xml version="1.0" encoding="UTF-8"?>
<nifty>
    <screen id="myNiftyScreen">
        <layer id="background" layout="horizontal">
            <panel childLayout="vertical" backgroundColor="#0f0f">
                <panel backgroundColor="#080f">
                    <text font="atomic.fnt" text="HELLO WOLRD!" align="center" color="#000f"/>
                </panel>
            </panel>
        </layer>
        
    </screen>
</nifty>



this is my java class that uses that xml

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package praktisan;

import com.jme.app.SimpleGame;
import com.jme.util.resource.ClasspathResourceLocator;
import com.jme.util.resource.RelativeResourceLocator;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.jme.input.JmeInputSystem;
import de.lessvoid.nifty.jme.render.JmeRenderDevice;
import de.lessvoid.nifty.jme.sound.JmeSoundDevice;
import de.lessvoid.nifty.sound.SoundSystem;
import de.lessvoid.nifty.tools.TimeProvider;
import java.net.URL;


/**
 *
 * @author dru
 */
public class TestNifty extends SimpleGame {
    
    private Nifty nifty;

    public static void main(String[] args) {
        TestNifty app = new TestNifty();
        app.setConfigShowMode(ConfigShowMode.AlwaysShow);
        app.start();
    }

    protected void simpleInitGame() {

        try {
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new ClasspathResourceLocator());
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new RelativeResourceLocator(new URL("file","",".")));
        } catch (Exception e) {
             e.printStackTrace();
        }

        nifty = new Nifty(new JmeRenderDevice(), new JmeSoundDevice(), new JmeInputSystem(), new TimeProvider());

        nifty.fromXml("praktisan/nifty2.xml", "myNiftyScreen");
        
    }

    protected void simpleRender() {
        nifty.render(false);
    }
}


and how do you render your nifty, sorry im a total newbie..

Obviously it can't find your font file.

Try first with default font? :slight_smile:

cant find the default font too… my atomic font is in the project's src folder…



Where do classPathResourcelocator and relativeResourceLocator look for the files?



Thank you