[quote=“phu004,post:20,topic:43697”]
Did you run the application after you finished compiling? Because the test run during the compilation wizard is slowed down a lot (because of profiling stuff happening on the background). But other than that I did not notice slowdowns for the things I compiled so far.
Lets back up for a moment. Launch4j (suggested earlier) has all of that, you don’t need to play around with NSIS scripts, write a custom C++ stub or AOT compile your application. With Launch4j you can configure such that it will use either the local JRE (if it is found) or the packaged JRE.
You don’t need to write a C++ stub, albeit it would be incredibly easy and there are probably tons of libraries that allow you to do it more cleanly.
[quote]Did you run the application after you finished compiling? Because the test run during the compilation wizard is slowed down a lot (because of profiling stuff happening on the background). But other than that I did not notice slowdowns for the things I compiled so far.
[/quote]
Yes, the application was run when everything is finished. The exe version takes twice amount of cpu usage for the same frame rate. I have uploaded my app here, I am really curious to see if it makes a difference on your side
That’s odd. I use Launch4j and it works fine with the LWJGL libraries along side the .exe in a libs folder. Are you sure you setup the path right in the jar before you created the .exe?
An advantage to writing a C++ stub is that under processes you will see your games name instead of javaw.exe however this doesn’t really make a difference to most users. Another might be that you could trim the JVM a little more when using a C++ stub because you don’t need the JVM .exe’s with a C++ stub and JNI. However I’ve never tried to slim down a JVM and package it with an .exe using Launch4j.
However, relative to the all your dependencies, java’s exe stub is probably negligent in size. Also launch4j does allow you to customize the process name.
(I have to write this in brackets because currently 90% of my post consists of quotes.)
I’d definitely also recommend launch4j for Windows packages. A single fat jar isn’t a requirement, your project can have any structure, and your process can be launched with custom names, not java.exe.
I’ve also used NSIS for installers, which was also very nice.
I’ve also heard rumors that the JavaFX native packaging works for all Java apps, not just JavaFX ones (another linky). If so, that’s a nice option because it creates native bundles for Windows, OS X and Linux.
I’m sorry for the late reply but there’s a lot of new stuff here and none of it is obvious to me. I have so far tried :
C++ route but just became rather lost and frustrated. I also couldn’t see how it would work on machines without java installed.
Excelsior JET but the licensing doesn’t suit me and I was hoping for a free solution
Launch4J looks promosing and it seems to have everything I want but I’m currently stuck trying to include a jre in the build. Any ideas?
It seems a shame that there isn’t a standard option in Java to just produce an exe (if windows). I know the golden ideal was to have safe code that could be run anywhere but these days I get more warnings trying to run my own jar files than I do running a random exe of the web. Users also seem more comfortable running exe’s. Weird.
[quote=“Jeremy,post:30,topic:43697”]
The statement that it can be done in C++ doesn’t necessarily indicate how it is done. This is further compounded by the fact I don’t do C++. I can state that you can write a chess program in Java, I could even talk about game trees, alpha beta pruning, transposition tables and zorbrist hashing but I’d guess it wouldn’t help you produce the program. I’m afraid I just don’t have enough info to move forward.
No, I mean, you said you can’t get Launch4J working because you are stuck trying to include the JRE in the build. What is the problem there? There is a tab, just browse to it and select where the JRE is you’d like to package.
It’s saying that it can’t find the bundled jre. I’ve tried various combinations but I guess I’ve yet to find the right combo. I’m pretty uselss at this stuff and tend to resort to guesswork until something works.
I have an AlienSwarm directory that contains my jar, classes, images etc. It now also contains a jre7 directory that is a straight copy of the standard jre7 directory. I comile the program using the following:
E:\Dropbox\Projects\AlienSwarm>javac AlienSwarm.java
Note: AlienSwarm.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
E:\Dropbox\Projects\AlienSwarm>jar -cfm AlienSwarm.jar Manifest.txt *.class *.wav *.png *.dat *.ico jre7
And then I use the Launch4J app to package the lot. I’m pretty sure it’s including the jre7 directory because the exe size has now jumped to around 50MB from around 1.5MB. Within the Launch4J app it asks for a bundled jre path and I enter “./jre7” I also tried “…/jre7” but with the same results. Obviously without the quotes.
Any ideas?
Mike
PS the error message is “This application was configured to use a bundled Java Runtime Environment but the run time is either missing or corrupt”
There is directory E:\Dropbox\Projects\AlienSwarm\jre7\bin that contains the file javaw.exe but I’m not sure if I’ve set the right bundled JRE directory.
If I change the dir to ./jre then it runs on a machine that has a current version of java but fails with the error message in my previous post.
I’m developing on Win 7 (64 bit) but the PC’s that will run the game are likely to be anything from Win 7 to DOS (yea really). The PC I tested on and where I got the error msg was XP. Linux doesn’t matter for this release - those who run Linux and want to run the program are quite likely to have the latest JRE anyway.
My game is a little over 1MB in the original Jar and this was mostly due to a music clip. When I copied the jre7 directory into the local direcortory of the game and included it in the jar - the file size jumped to 50MB. Is it just the bin dir within the jre7 dir I should include?
On the win 7 PC the normal dir is E:\Program Files\Java\jre7\bin
The dir containing the game is E:\Dropbox\Projects\AlienSwarm
The dir now continaing the copied jre7 is E:\Dropbox\Projects\AlienSwarm\jre7\bin
On the XP machine there isn’t such a dir as Java isn’t installed.
It’s difficult explaining things when you’re not quite sure how things function - I assume there isn’t a log file I can show that list all the info required?
You spotted my deliberate mistake I think I had that originally but then accidentally left that in while trying various random changes to see if I could make it work.
Unfortunately the change didn’t fix things though and I still get the same error but oddly:
I can run the exe locally on my Win 7 machine but then I have the latest JRE so it wouldn’t look for the bundled JRE
If I copy the exe to my NAS device I can’t run it from there on my local machine (see error above in red)
Same thing happens if I use my XP machine with no on board java
If I copy the exe to my XP machine and run it then I still get this error
???
Obviously the file size is still a very hefty 50MB.
you should take a took at the windows package for Droid Assault or for my game Daedalus to have an idea of the final file structure of a java application packaged with a tool like launch4j.
There is something you obviously missed: the JRE should not be inside the jar. At the end you should have an exe file that contains or not your code + resources depending on what you choosed in launch4J config file. And next to the jar you will have the JRE folder. The exe will try to run the system JRE or the one you provide again depending on your config.
Take a look at my game package, I think it will become obvious to you after seeing it