Java games on PC's with no Java?

I have a java web start game which people with Java happily play but many folks don’t have Java and don’t want to install Java. I tried zipping the jar and including java.exe in the zip, then I had a small windows bat file that calls the java.exe to run the jar. It worked fine on my machine but then I already have Java. It didn’t work on PC’s with no Java or an out of date Java.

Bat file is:

[quote]java.exe -jar -Dsun.java2d.noddraw=true AlienSwarm.jar FULLSCREEN 2>tmp.log

exit;
[/quote]
Any ideas?

Have you tried using something like JSmooth or IzPack? Or an equivalent pseudo automated packager?

Something that can bundle a full java JRE with your game, so that you don’t depend upon an existing jre install?

Hi Mike, take a look at our games for a way to do it. We use a custom C++ launcher on Windows but OSX and Linux just use shellscript. The C++ launcher is pretty trivial to make.

Cas :slight_smile:

Thanks for the very fast replies guys!

Jsmooth - will this just run the java.exe program in my zip file? I want to avoid the program even mentioning to the user that it’s running Java. The people running my program are putting it into arcade machines and obviously they just want it to run rather than show popups saying that your Java needs updating. Is it easy to use?

IzPack - same questions as above really.

C++ - I program in many languages but unfortunately C++ isn’t one of them. Is there an example somewhere of how to do this? Was this how you put your Revenge of the Titans onto steam? Did you produce a blog/txt/post of how you did this and whether it was worth the effort. Obviously my little program isn’t as flash as yours but it can be quite addictive and people seem to enjoy playing it so it would be nice to make a few pennies from the effort.

I remind you that you can use some options of Java Web Start to hide some elements so that they never see it requires Java. You can then provide the JRE and use Java Web Start, maybe look at the “-import” option. IzPack has no automatic update but if you want to use it, you can look at some free softwares using it, for example Art Of Illusion.

I’m afraid I’ve not blogged about it or anything much but I’ll put some C++ code in the pastebin for you to peer at: http://pastebin.java-gaming.org/6f78e8e8d6a
It can be a bit simpler than that :wink:

Cas :slight_smile:

I use batch to exe. Just create a batch file, package your own private jre and there you go.

If you don’t want to mess with C++ for an installer I highly recommend NSIS.

I combine that with Cero’s technique and it works quite well.

Yeah, I use NSIS as well

You can also use Launch4j to wrap a runnable jar file into a Windows executable. Launch4j has support for embedding a JRE.

Only including java.exe will not work, by the way, since the java runtime environment requires many other files to function. Take a look at the JRE installation on your computer (e.g. c:\program files\java\jre7 or something), it will be over 100MB in size. You van reduce the size of the Oracle JRE (which is by the way perfectly legal to redistribute along with your app) by leaving out some files and doing other tricks. There’s a good answer on StackOverflow on how to do this. Still, expect a somewhat sizeable installation file, although that is hardly a problem these days.

Personally I use Excelsior JET, that integrates its own virtual machine into the compiled executable, but that is somewhat expensive for indie developers (I got it in a charity deal). I like this one because it lets me reduce the size of the resulting executable further than most other approaches (say to under 10MB including runtime), and its pretty easy to use and maintain.

Jet’s great.

Batch to EXE is interesting, never seen that before though I suppose it’s obvious such a thing must have existed.

I tried Molebox as well but it falls foul of so many virus checkers I’ve had to abandon it once more.

Cas :slight_smile:

Grunnt, at first I was like damn. I wish I could use Excelsior JET, that seems super cool, but its soo expensive! You are lucky!

Then I went hmmmmmmm ???

Searched my email and :o realized some 8 months ago, I got it for $10 during that same charity deal ;D

Quite a lot of choices and I find it difficult picking an option

3PgbNQU3cYo

Do any of the above satisfy the following?

  • My budget is currently around $0
  • My users often don’t have Java and/or don’t want Java
  • A precious few seem to have old versions of Java
  • None want to see popups appearing telling them to download the latest Java or asking whether they really want to run the program
  • Many actively don’t want to instal Java because of perceived security issues etc
  • I guess they’d prefer an exe if they had the choice - I know this rules out Linux but I guess they can run the standard jar.

PS can anyone PM me on how to get the youtube video appearing? (I tried help and half a dozen random formats)

@princec

Where did this come from?


#if defined(STEAM)

I’ve seen things like


#ifdef STEAM

Also can you explain why are you having two main methods?


int main(const int& argc, const char ** argv)
{
   return startup((LPSTR) argv[1]);
}

/*
 * Invoke our embedded JVM
 */
int WINAPI WinMain
(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
   return startup(lpCmdLine);
}

You just use the video id tag after the ?v=
without spaces:
[ youtube ] 3PgbNQU3cYo [ / youtube ]

3PgbNQU3cYo

STEAM is used when I’m building Steam deployments.
The ordinary main() method is for when I’m building console deployments so I can run from the commandline easily.

Cas :slight_smile:

@mike_bike_kite

Yes your requirements are absolutely valid.
Ship/include your own jre or openjdk jre whatever, create a batch, use batch to exe; and then for the installer if you need one, use NSIS

If you like using nsis, you can create a simple script that has all your jar files in it. Here is it.


;This is a very simple Java Launcher
;Author: Sri Harsha Chilakapati
 
!include FileFunc.nsh
Crccheck off
 
;icon icon.ico
outfile runner.exe
 
silentinstall silent
 
section '1'
sectionend
 
function .onInit
    ${GetExeName} $0
    ${GetParameters} $1
    execwait 'Runtime/bin/javaw.exe "$0" "$1"'
functionend
 
;usage: copy /b runner.exe+myjar.jar output.exe

Then copy the files you required in the jre to the folder Runtime. Now compile this script to produce the [icode]runner.exe[/icode]

Now makesure that you have a single jar file, use Jarsplice. Then in [icode]cmd[/icode] type


copy /b runner.exe+myjar.jar output.exe

Now running this exe should open the game. Here’s the folder structure.


Game Directory
   |
   --> output.exe // Your exe
   |
   --> Runtime Directory
          |
          --> jre installation
                 |
                 --> bin Directory // Contains javaw.exe

It’s the same concept that is used in SFX archives.

I personally never put assets in jars. Kinda dont like it. Works either way

I have only tried the evaluation version of Excelsior JET, it works. But the performance of my application becomes a lot worse , even with all the optimization options selected. I am not sure whether it is because I was using the trial version or I chose the wrong optimization option.