Any other way besides jarsplice? I really would prefer to have a single file for the consumer to download other than having them choose from 3. Just a connivence thing.
you could always use one of the installer maker programs, or a zip file.
What’s wrong with JarSplice?
I just feel like there could be a way more efficient way.
Efficient in what sense?
Shameless self-promotion: I created a tool that does exactly what you’re talking about, available here: JarMatey
Native packaging in Netbeans using Inno 5 setup. Creates an exe installer which packages a java runtime as well. Works really well and easy to use. Also alternative native packaging for Linux and mac.
I created a very hacky Launcher.class to get around jarsplice so I can directly export and run the game without any fiddling after.
It’s been tested to work on Mac, Linux and Windows.
package rpc.launcher;
public class Launcher {
public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, FileNotFoundException{
String nativesFolder = new File("lib/natives").getAbsolutePath();
String jarFolder = new File("lib/jar").getAbsolutePath();
System.setProperty("java.library.path", nativesFolder+";"+jarFolder+";"+System.getProperty("java.library.path"));
System.setProperty("org.lwjgl.librarypath", nativesFolder);
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
sysPathsField.setAccessible(true);
sysPathsField.set(null, null);
Game.launchGame();
}
}
That’s the entire class, and it executes before Slick2d and LWJGL are loaded, it’s all super hacky code, but it gets the job done quite effectively. Note that Game.launchGame(); is pointing to your what used to be your old main method with all the usual game launch code in it.
Obviously you’ll have to change the file paths to wherever your natives are stored, I just stuck all the natives together in one folder called /lib/natives/ and the jars (Slick2d, LWJGL, etc) in /lib/jar/
And you can go even further with a fat jar by using JarInputStream or whatever to unpack the natives into “lib/natives” or temp directory etc.
Tested this program out. It works like a charm. I’ve already recommended it to my friends haha. This program is exactly what I was looking for! Thanks!
Awesome, glad it works for you!
Shameless self-promotion ;D My zipped .app file works like a charm under Mac OS X (it contains a JRE too), my (DEB and RPM) GNU Linux packages will probably work in a few weeks and my MSI packages will work in some months under Windows. I use LibGDX Packr + JDeb + Redline RPM + Apache POIFS + Apache Commons Imaging + Ant. It is 100% cross-platform, it means that you don’t have to be under the targeted OS to build your packages (even the .icns icon file for Mac). It is very flexible, you can choose to use the system JVM (then modify the native launcher or replace it by a simple script) or to put your own JRE into your packages. You can find some information about my attempt here and in the Ant script of Truly Unusual Experience of Revolution®.
In my humble opinion, it will become much better than existing solutions based on executable JARs because it is highly possible that the OS will know how to open my native packages and no web browser will mess with them whereas when I download a JAR with Firefox under Windows, it wraps it into another JAR, it breaks it Sometimes, the default archiver tries to open the JAR instead of allowing Java to run the game
My solution works very well with JogAmp and/or LibGDX as is but it needs a tiny supplementary effort to modify the Java library path if you use some native libraries.