I would not recommend using libGDX for a headless environment, it just isn't intended to be used that way, and you might run into problems in the future, as the libGDX command changes structure. However, since Rod noted that it is possible to do this, and below is a snippet of how you do it. To initialize the global Gdx.files, you will need to create a class in the backend package and configure the global variables yourself:
package com.badlogic.gdx.backends.lwjgl; import com.badlogic.gdx.Gdx; public class Headless { public static void loadHeadless() { LwjglNativesLoader.load(); Gdx.files = new LwjglFiles(); } }
The rest should be pretty simple. Just call Headless.loadHeadless (); at the beginning, and then you should be able to use parts of the required structure.
As I said, I would not suggest doing this, but I did not find good solutions for using libgdx with a client / server architecture.
Edit :
Some time ago (after I wrote this answer initially) libgdx added a headless backend that is designed for this kind of purpose. This is the correct and correct way to use libgdx in a headless environment and works very well for creating a server using libgdx.
source share