Lets say i have a game written with JOGL. How do i get it so when i give it to a different person that doesn’t have JOGL, it installs it into their JRE. Can i do this just with some added programming into the main() and then make it into a jar? Hopefully this question makes sense, and isn’t too noobish.
Well, the easiest thing to, would be to package your game with jogl.jar and the binary files needed for different platforms.
Then create launcher scripts for the different platforms:
For example, Linux:
java -Djava.library.path="./" -cp ./<folderWhereJOGL.jarIs> -jar YourGame.jar
Same thing goes for windows, you can create a .bat file which does similar stuff.
Then you would zip up everything, including your game (as a .jar file?), jogl.jar and the binaries for each platform + the launcher scripts. Then, you would not have to clutter up the jre. (For example, in linux, a normal user does not (usually) have write access to the JRE folder. So, to be able to “install” your game, the user would need root privileges, which is not sure the user has access to). Of course, in windows, this wouldnt be a problem as everybody is used to run with administrator privileges anyway . Its a lot smoother to keep everything as clean and self contained as possible.
Not sure about the licence of jogl, but I think you can redistribute it freely, as long as the copyright notice stays with the jar file, and you dont promote your game by mentioning Sun Microsystems in any way.
There is a small thread regarding licence here:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1108729206
Hope this helps.
Btw… Not sure if the above command works as it is, I wrote it freely from memory. You might want to google around a bit to find some examples.
Use Java Web Start. This is how all of the JOGL demos are distributed. The end user needs to install a JRE, but once that’s done, all JRE updates as well as downloading and installing your game and any required libraries is completely automatic.
Ok, was a bit curious on this myself… Below is a command that works.
The directory structure is as follows (For example, this is how you would package your .jar file):
Contents of YourGame.zip
/lib
- jogl.jar
/natives-linux
-libjogl.so
-libjogl_cg.so
/natives-win
-libjogl.dll
-libjogl_cg.dll
/game
-YourGame.jar
StartGame.bat
StartGame.sh
Three folders: lib, natives and game.
The contents of StartGame.bat:
java -cp ./lib/jogl.jar:./game/YourGame.jar -Djava.library.path=./natives-win your.package.name.goes.here.MainGameClass
the -cp parameter:
*This tells the JVM where to look for classes. You would include all the libraries you are using here, separate them by a colon.
The -Djava.library.path:
*This tells the JVM where to look for native libraries. All other DLL or SO files you are using should be set with this command.
The last parameter is the main executable class for your game. If you dont use a package for your files (Strongly encouraged though), then just put the class name there.
The contents of StartGame.sh:
java -cp ./lib/jogl.jar:./game/YourGame.jar -Djava.library.path=./natives-linux your.package.name.goes.here.MainGameClass
And, voila… You have yourself a totally nice and clean package. No install needed. Just unzip, and run. I havent tested out the windows command, maybe you need to swap file separators ( from / to \ ) but I dont know. (Note that the . needs to be there.)
Hope this helps.
Or, you can use Java Web Start
I don’t wan’t to do web start, because I don’t want to distribute it on the internet. I will try the command thingy and get back to you if problems arise. Thanks for your help.
You may use open source installer makers…
http://www.izforge.com/izpack/
This project creates installer from a java project…
I use it for my game project too…