Rasenger
Just dropped in
Offline
Posts: 9
|
 |
« on: 17. February 2009, 09:46:21 am » |
|
More questions from a noob. I have a working project I made using Eclipse, and it runs fine from there. But I have no idea how to run the program without Eclipse. If I run it with a batch file with command "java ArcadeWar" it won't work, of course. I'd like to know how it can be run from command line, what libraries or dll's or whatever should I add and where... I'm totally confused. Or should I somehow build a jar file?
|
|
|
|
|
Logged
|
|
|
|
|
lonesomeStranger
|
 |
« Reply #1 on: 17. February 2009, 01:40:35 pm » |
|
Try to read this. Also, you can look at testlauncher.bat from xith-tk project for example.
|
|
|
|
|
Logged
|
Anton
|
|
|
Gunslinger
Enjoying the stay
Offline
Posts: 44
|
 |
« Reply #2 on: 17. February 2009, 03:13:26 pm » |
|
There are two ways, jar or java web start. Java web start depends on jar.
The following will help lots: Use ant. Eclipse has support for it. Make a build script that compiles your project, packages it into a jar (or probably two), signs it and copies it to a server (when I get home I can post my buildfile that does all this).
Once this is done, you can almost run the program by clicking the jar (or executing "java -jar yourgame.jar"). But you will also need the natives for jogl or lwjgl. This is much simpler if you descide to use webstart, but not impossible with a simple jar.
If you want to deliver a jar you have to deliver the natives as well. You then have to make a batch-file och shell-script that starts the program with the extra parameter -Djava.library.path=<Path to natives>
If you use webstart, the webstart file simply points to jogl or lwjgl, and java will download it automatically. This is one row in a file and you don't have to care about attaching natives for all different OSes.
A second advantage with webstart is that your users will get all the latest updates each time they run your program. Webstart actually checks all your files, detects what needs to be updated, downloads it, installs it and runs the program. This is the reason to split your project into several jars. Hopefully you will change the code more often than you change the resources. And the resources are the bigger part. So on each upgrade, the user only have to download a small file, instead of the whole blob.
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #3 on: 17. February 2009, 08:11:01 pm » |
|
You description of the Webstart-way sounds very interesting. But if you want to release your game as a stand-alone app, you can also simply use Eclipse to export a jar file (without ant). Just right-click the application and select Export->Jar File. Then use textlauncher.sh/testlauncher.bat as an example for creating a launch script and you're through. Don't forget to save a jardesc, so that you can refresh the jar by simply klicking the jardesc and selecting "create jar".
Marvin
|
|
|
|
|
Logged
|
|
|
|
Rasenger
Just dropped in
Offline
Posts: 9
|
 |
« Reply #4 on: 18. February 2009, 10:06:33 am » |
|
But if you want to release your game as a stand-alone app, you can also simply use Eclipse to export a jar file (without ant). Just right-click the application and select Export->Jar File. Then use textlauncher.sh/testlauncher.bat as an example for creating a launch script and you're through.
Thanks, I got it working. I still have one problem: I used Fat Jar to create one jar file that includes all the needed bytecode files, but I can't run it. I tried using: java -Djava.library.path="Libraries\Natives;" -classpath "Libraries\xith3d.jar;Libraries\lwjgl.jar;Libraries\openmali.jar;Libraries\jagatoo.jar;" -jar ArcadeWar.jar but seems to not find the library files or something. Manifest file is also correct.
|
|
|
|
« Last Edit: 18. February 2009, 04:59:01 pm by Rasenger »
|
Logged
|
|
|
|
Rasenger
Just dropped in
Offline
Posts: 9
|
 |
« Reply #5 on: 19. February 2009, 06:38:32 pm » |
|
I've made some progress. I've made an executable jar that has a manifest that has line "Class-Path: xxx". Now when I run the jar, there are no errors caused by the libraries, but it seems that the program can't find lwjgl.dll. I've tried to put it in the same folder, and to specify it's location with this code: System.setProperty("java.library.path", "Libraries/Native/"); System.load("Libraries/Natives/lwjgl.dll"); Doesn't work. Oh, and the error report: 
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #6 on: 19. February 2009, 08:39:36 pm » |
|
Please use testlauncher.bat as an example. Build your jar as a normal jar with only your classes in it. Then replace the xith-tk.jar with your jar in the batch file. This should work. The native libraries are already correctly included in this file.
Marvin
|
|
|
|
|
Logged
|
|
|
|
Rasenger
Just dropped in
Offline
Posts: 9
|
 |
« Reply #7 on: 20. February 2009, 12:43:32 pm » |
|
I didn't quite understand. The game runs fine when I execute it using a bat that tells library path and class path to java (so the bat executes ArcadeWar.class). When I create a jar in the same folder that includes the class files, the game won't run if I double click the jar file, or use command line to execute it (ArcadeWar.jar). What does the test-launcher have to do with this?
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #8 on: 20. February 2009, 02:39:13 pm » |
|
I didn't quite understand. The game runs fine when I execute it using a bat that tells library path and class path to java (so the bat executes ArcadeWar.class). When I create a jar in the same folder that includes the class files, the game won't run if I double click the jar file, or use command line to execute it (ArcadeWar.jar). What does the test-launcher have to do with this?
The testlauncher batch or shell script includes all the necessary jars and native libraries. Xith needs a lot of them. Did you ever have a look at the testlauncher.bat? There's not just "java -jar xith-tk.jar", but very much more jars are included. If you build a jar file with only your packages and classes in it and the appropriate folder structure, whare all your jars and natives are in, you can use a batch file like this to run your game: @echo off
set ROOT=%CD%\ set THIRD=%ROOT%third-party set LIBS=%ROOT%libs set TEST=%ROOT%test set PATH=%PATH%;
java -Djava.library.path="%THIRD%\gluegen\windows-i586\;%THIRD%\jogl\windows-i586\;%THIRD%\lwjgl\win32;%THIRD%\joal\windows-i586" -Xms64m -Xmx128m -classpath "%THIRD%\gluegen\gluegen-rt.jar;%THIRD%\jogl\jogl.jar;%THIRD%\lwjgl\lwjgl.jar;%THIRD%\joal\joal.jar;%THIRD%\sound\vorbis.jar;%THIRD%\math\openmali.jar;%THIRD%\jagatoo.jar;%THIRD%\physics\joode.jar;%THIRD%\physics\xpal-joode.jar;%LIBS%\xith3d.jar;%THIRD%\particles\jops.jar;resources\media.jar;resources\hud-themes.jar;%LIBS%\your-game.jar" org.yourgame.YourGame
Marvin
|
|
|
|
|
Logged
|
|
|
|
Gunslinger
Enjoying the stay
Offline
Posts: 44
|
 |
« Reply #9 on: 21. February 2009, 06:43:24 am » |
|
This is a simple way to build your project and get a runnable jar-file (still needs natives though). You have to copy the external jars to the dist folder (write some more ant tasks for this) and you have to sign them (look below how to do this with ant). After this, you can run your game with a simple bat (only needs path to natives). Also, if you want to use webstart, this is almost complete. Place a jnlp-file in the same directory and upload everything to a webserver. This way, you don't have to worry about natives. <?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build-all" name="your-game">
<target name="compile"> <!-- compiled classes and resources go to folder: classes (old habit) --> <mkdir dir="classes"/> <javac srcdir="src" destdir="classes" classpathref="xithcp" target="1.5"/> </target>
<path id="xithcp"> <!-- May need more here --> <pathelement path="pathto/jagatoo.jar"/> <pathelement path="pathto/openmali.jar"/> <pathelement path="pathto/swt.jar"/> <pathelement path="pathto/xith3d.jar"/> </path>
<target name="copy-resources"> <!-- I assume you have your resources under a dir named resources --> <mkdir dir="classes"/> <copy todir="classes" verbose="true"> <fileset dir="src"> <exclude name="**/*.java"/> <exclude name="**/somemore"/> </fileset> </copy> </target>
<target name="jar" depends="compile, copy-resources" > <jar destfile="dist/yourgame.jar" basedir="classes" compress="false" includes="yourpackade/**"> <manifest> <attribute name="Main-Class" value="your.package.YourMainClass" /> <attribute name="Class-Path" value="xith3d.jar jagatoo.jar openmali.jar lwjgl.jar yourgame-resources.jar hud-themes.jar"/> </manifest> </jar> <jar destfile="dist/yourgame-resources.jar" basedir="classes" compress="false" includes="resources/**"> </jar> <signjar keystore="yourkey.ks" jar="dist/yourgame.jar" alias="You" storepass="xyz" /> <signjar keystore="yourkey.ks" jar="dist/yourgame-resources.jar" alias="You" storepass="xyz" /> </target>
<target name="Gen key"> <delete file="yourkey.ks"/> <genkey alias="You" keyalg="RSA" storepass="xyz" keypass="xyz" keystore="yourkey.ks" validity="1000" > <dname> <!-- this might not be entirely true, but it works --> <param name="CN" value="Your Name"/> <param name="OU" value="Your Game"/> <param name="O" value="Your company"/> <param name="C" value="your location"/> </dname> </genkey> </target>
</project>
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #10 on: 21. February 2009, 12:32:34 pm » |
|
This is a simple way to build your project and get a runnable jar-file (still needs natives though). You have to copy the external jars to the dist folder (write some more ant tasks for this) and you have to sign them (look below how to do this with ant). After this, you can run your game with a simple bat (only needs path to natives).
I don't want to be contradictory. Your way is certainly a good one. Bur if you just want to distribute your game as a standalone application (like regular games), you don't need to sign your jars and my above solution is the simples using eclipse, since it very easily creates jars. but if you want to use WebStart you do have to sign them and your way is certainly one of the best ones. Marvin
|
|
|
|
|
Logged
|
|
|
|
Gunslinger
Enjoying the stay
Offline
Posts: 44
|
 |
« Reply #11 on: 21. February 2009, 06:42:09 pm » |
|
I don't want to be contradictory. Your way is certainly a good one. Bur if you just want to distribute your game as a standalone application (like regular games), you don't need to sign your jars and my above solution is the simples using eclipse, since it very easily creates jars. but if you want to use WebStart you do have to sign them and your way is certainly one of the best ones. You are right of course, I'm just keeping all options open 
|
|
|
|
|
Logged
|
|
|
|
|
Andre Pohlmann
|
 |
« Reply #12 on: 16. October 2011, 01:26:07 pm » |
|
Hi @all,
got several problem with deploying a project.
- deploy via fat.jar: no lwjg or problem with the renderloop. - via ant: the same after several tries - testlauncher: class not found - renderloop - oneclick: doesn't start the project
From my point of view the deployment has to become a way more simple. project/projetc.jar project/lib/(what's needed here?) and if something doesn't work there should be a better information.
Is there a manual for that?
Regards AP
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #13 on: 17. October 2011, 07:51:49 am » |
|
Hi Andre,
no, there is no manual for that. There is just the xith-tk project, that has a working classpath, which you can use as an example.
I wouldn't go for a fatjar solution, but write a custom URLClassLoader to load all the jars myself from one host jar.
|
|
|
|
|
Logged
|
|
|
|
|