Distribution issue?

I’m writing some client/server code. Running the server (localhost) is an issue. I run the app in the IDE and everything is fine. I run the JAR outside the IDE and I get the standard settings dialog, select the settings I want and click OK…then nothing.



Obviously something is wrong, but I have no way to find out what it could be. I use no assets whatsoever, and I’m starting the app from the DIST directory.



As usual, it’s probably something obvious…thanks in advance for your help!

Oh hmm, you absolutely sure you use no assets?. The only time this has been as issue for me with JME, is when I hadn’t converted my models to .j3o format, because these formats will be excluded by default: /*.mesh.xml,/.skeleton.xml,**/.scene,/*.material,/.obj,**/.mtl,**/*.j3odata. Like i say there was no warning, the UI controls appear, click OK, then there’s a flash and nothing happens. If this is the case, make sure your doing a clean build, and if that doesn’t work try making a new project and move the files into there.

Yep, no assets. I add a BitmapText to the guiNode to display messages received by the server, that’s it. No models, materials, etc. explicitly created but I have no idea what happens in the background. Pasting my code below…it’s short.







pre type="java"
import com.jme3.app.SimpleApplication;


import com.jme3.input.KeyInput;


import com.jme3.input.controls.ActionListener;


import com.jme3.input.controls.KeyTrigger;


import com.jme3.network.connection.Client;


import com.jme3.network.connection.Server;


import com.jme3.network.events.ConnectionListener;


import com.jme3.network.events.MessageListener;


import com.jme3.network.message.Message;


import com.jme3.renderer.RenderManager;


import java.io.IOException;


import java.util.logging.Level;


import java.util.logging.Logger;


import com.jme3.font.BitmapText;


import com.jme3.font.Rectangle;


import com.jme3.math.ColorRGBA;





/**


 


 
 @author admin


 */


public class Main extends SimpleApplication implements ActionListener, ConnectionListener, MessageListener {





    Server server;


    static Main app;


    BitmapText console;


    ScrollText text = new ScrollText();





    public static void main(String[] args) {


        Logger.getLogger(“com.jme3”).setLevel(Level.SEVERE);


        app = new Main();


        app.start();


    }





    @Override


    public void simpleInitApp() {








    flyCam.setDragToRotate(true);


    try {


        server = new Server(55551, 55551);


        server.addConnectionListener(this);


        server.addMessageListener(this);


        server.start();


        //System.out.println(“Server started, listening on 55551”);


     } catch (IOException e) {


        e.printStackTrace();


     }





    inputManager.deleteMapping(“FLYCAM_ZoomIn”);


    inputManager.deleteMapping(“FLYCAM_ZoomOut”);


    inputManager.clearMappings();


    inputManager.addMapping(“cmd_STOP”,  new KeyTrigger(KeyInput.KEY_ESCAPE));


    inputManager.addListener(this, “cmd_STOP”);





    int screenwidth = settings.getWidth();


    int screenheight = settings.getHeight();





    console = new BitmapText(guiFont, false);


    console.setSize(guiFont.getCharSet().getRenderedSize());      // font size


    console.setColor(ColorRGBA.White);                             // font color


    text.addLine(“Initialized.”);


    console.setText(text.getText()); // the text


    Rectangle r = new Rectangle(20, 350, 500, 50);


    console.setBox®;





    //hudText.setLocalTranslation(300, hudText.getLineHeight()*5, 0); // position


    guiNode.attachChild(console);








    }


    @Override


    public void clientConnected(Client c) {


        text.addLine(“Connected: " + c);


    }


    @Override


    public void clientDisconnected(Client c) {


        text.addLine(“Disconnected: " + c);


    }


    @Override


    public void messageReceived(Message msg) {





    }


    @Override


    public void messageSent(Message arg0) {


        // TODO Auto-generated method stub


    }


    @Override


    public void objectReceived(Object arg0) {


        // TODO Auto-generated method stub


    }


    @Override


    public void objectSent(Object arg0) {


        // TODO Auto-generated method stub


    }





    @Override


    public void simpleUpdate(float tpf) {


        console.setText(text.getText()); // the text


    }





    @Override


    public void simpleRender(RenderManager rm) {


        //TODO: add render code


    }





    @Override


    public void onAction(String name, boolean keyPressed, float tpf) {





        if (name.equals(“cmd_STOP”) && !keyPressed)    {


            try {


                //System.out.println(“Shutting down server by user request…”);


                server.stop();


            } catch (IOException ex) {


                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);


            }


            //System.out.println(“Stopping application…”);


            app.stop();


        }


    }





    class ScrollText    {


        String[] lines = new String[50];


        String out;





        public ScrollText() {


            out = “”;


            for (int i = 0; i<50; i++)  {


                lines = “”;


            }


        }


        public void addLine(String s)   {


            out = “”;


            for (int i = 49; i>0; i–)  {


                lines = lines[i-1];


                if (!lines.equalsIgnoreCase(””)) {


                    out = out + lines;


                }


            }


            lines[0] = s + “nr”;


            out = out + lines[0];


        }


        public void clear() {


            for (int i = 0; i<50; i++)  {


                lines = “”;


            }


            out = “”;


        }


        public String getText()   {


            return out;


        }





    }


}
/pre

Maybe try to use the Logger with Level.INFO will give some output and maybe give some clue as to what’s happening?



If you’re on windows, you might also try to start the jar directly from a CMD window instead of double-clicking. I have noticed that sometimes output (System.out…) will be redirected to the console. But not always.



Hopefully those might help.

Looks like you are using old SpiderMonkey… I can’t say this is the problem for sure but the “never connecting” was a known issue because it had some pretty serious internal threading issues. I completely rewrote it a few months back.

I would love to use the new API…actually thought I was based on an example I found. Is there a sample or tutorial somewhere for the new code?

I think the only article is the one I wrote on transitioning that also has an overview. Everything in com.jme3.network.connection is deprecated. The public API is no in com.jme3.network and the other packages are just more of a supporting role… with a few being outright deprecated.



I/we have been really remiss in updating the tutorials but hopefully the transition document: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:networking has the information you are looking for.