When I export the default libgdx project as a runnable JAR file from eclipse and then run the .jar file, it simply pops up a black screen and then closes.
When I run the project code from inside Eclispe, it works fine. The correct red screen with the "bad logic" logo is displayed by the program (this is what is supposed to happen).
If I build the project from the command line using gradle with the command
gradlew desktop:dist
and then run the jar that is created, it will simply open up show a black screen for a second and then close.
The code being used is the default Java libgdx project code:
package com.mygdx.game.tesprac;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class TestLibgdx extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
}
Desktop Launcher:
package com.mygdx.game.tesprac.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.mygdx.game.tesprac.TestLibgdx;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new TestLibgdx(), config);
}
}