lwjgl Exiting my launcher and starting my game

I’ve set out on a journey to make the greatest (and my first) game in history, and like all great games I thought I’d have a launcher with options and such and a play button.

When finished adjusting one’s settings, which are stored in a .properties file, the idea is that one clicksplay to play, whereupon the launcher quits (and releases it’s resources) and the game starts.

The way I’ve done this is as follows:



public class Main {

	public static void main(String[] args) {
		if (new Engine().start()){
			System.out.println("gamestarting");

		}
	}

}


The engine class is the engine for my launcher. It returns true if play is pressed and false if exit is pressed.

Now, when the engine exits it does Display.destroy() and AL.destroy(), and since I don’t create a reference to my engine in the main method, I’m hoping the JVM throws away all resources associated with it, so that it doesn’t compromise the actual game when I run it.

However, if I do this:



public class Main {

	public static void main(String[] args) {
		if (new Engine().start()){
			new Engine().start();
		}
	}

}



I get exceptions. The first I get is this:

Exception in thread “main” java.lang.UnsatisfiedLinkError: org.lwjgl.openal.AL10.nalGenBuffers(IJ)V
at org.lwjgl.openal.AL10.nalGenBuffers(Native Method)
at org.lwjgl.openal.AL10.alGenBuffers(AL10.java:1019)
at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:714)
at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:683)
at org.newdawn.slick.openal.AudioLoader.getAudio(AudioLoader.java:54)
at components.audio.Sound.(Sound.java:15)
at launcher.Resources.(Resources.java:23)
at launcher.Engine.(Engine.java:47)
at main.main.Main.main(Main.java:10)

But I suspect there will be more.

My question is how I can solve this problem. Isn’t display.destroy() and AL.destroy() enough so that I can start from a clean slate?
What I’d really like to do is close down the entire JVM and start up the game, but I don’t know if that’s possible. Perhaps I can start my launcher as a thread and join it once it’s done. Would that clean the slate?