Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Java games on PC's with no Java?  (Read 3724 times)
0 Members and 1 Guest are viewing this topic.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Posted 2013-08-20 10:43:22 »

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;

Any ideas?

Arcade swarm
Board Chess - Checkers - Othello
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #1 - Posted 2013-08-20 10:45:54 »

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?

"Experience is what you get when you did not get what you wanted"
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2013-08-20 11:54:34 »

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 Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #3 - Posted 2013-08-20 12:33:12 »

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.

Arcade swarm
Board Chess - Checkers - Othello
Offline gouessej
« Reply #4 - Posted 2013-08-20 13:19:01 »

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.

Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2013-08-20 14:55:18 »

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 Smiley

Offline Cero
« Reply #6 - Posted 2013-08-21 00:31:53 »

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

Online BurntPizza
« Reply #7 - Posted 2013-08-21 00:39:41 »

C++ - I program in many languages but unfortunately C++ isn't one of them. Is there an example somewhere of how to do this?

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.
Offline Cero
« Reply #8 - Posted 2013-08-21 00:56:03 »

Yeah, I use NSIS as well

Offline Grunnt

JGO Wizard


Medals: 66
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #9 - Posted 2013-08-21 07:45:59 »

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.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2013-08-21 09:44:28 »

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 Smiley

Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #11 - Posted 2013-08-21 10:48:23 »

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  Huh

Searched my email and Shocked  realized some 8 months ago, I got it for $10 during that same charity deal  Grin


"Experience is what you get when you did not get what you wanted"
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #12 - Posted 2013-08-21 12:46:46 »

Quite a lot of choices and I find it difficult picking an option
<a href="http://www.youtube.com/v/3PgbNQU3cYo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/3PgbNQU3cYo?version=3&amp;hl=en_US&amp;start=</a>

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)

Arcade swarm
Board Chess - Checkers - Othello
Offline SHC
« Reply #13 - Posted 2013-08-21 12:55:55 »

@princec

Where did this come from?

1  
#if defined(STEAM)

I've seen things like

1  
#ifdef STEAM

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
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);
}

Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #14 - Posted 2013-08-21 13:08:48 »

Quite a lot of choices and I find it difficult picking an option
[youtube]http://www.youtube.com/watch?v=3PgbNQU3cYo[/youtube]

PS can anyone PM me on how to get the youtube video appearing? (I tried help and half a dozen random formats)
You just use the video id tag after the ?v=
without spaces:
[ youtube ] 3PgbNQU3cYo [ / youtube ]

<a href="http://www.youtube.com/v/3PgbNQU3cYo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/3PgbNQU3cYo?version=3&amp;hl=en_US&amp;start=</a>

"Experience is what you get when you did not get what you wanted"
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #15 - Posted 2013-08-21 14:29:23 »

@princec

Where did this come from?

1  
#if defined(STEAM)

I've seen things like

1  
#ifdef STEAM

Also can you explain why are you having two main methods?
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 Smiley

Offline Cero
« Reply #16 - Posted 2013-08-22 00:02:59 »

@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

Offline SHC
« Reply #17 - Posted 2013-08-22 05:33:41 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
;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
runner.exe


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

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

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
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.

Offline Cero
« Reply #18 - Posted 2013-08-22 17:18:07 »

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

Offline phu004

JGO Coder


Medals: 4
Projects: 9
Exp: 10 years


NoSuchPersonException


« Reply #19 - Posted 2013-08-24 01:44:33 »

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.
Offline Grunnt

JGO Wizard


Medals: 66
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #20 - Posted 2013-08-24 14:17:22 »

I am not sure whether  it is because I was using the trial version or I chose the wrong optimization option.

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.

Offline Jeremy
« Reply #21 - Posted 2013-08-24 18:24:57 »

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

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)

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.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline phu004

JGO Coder


Medals: 4
Projects: 9
Exp: 10 years


NoSuchPersonException


« Reply #22 - Posted 2013-08-25 08:32:13 »

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.

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 Smiley   
Offline Cero
« Reply #23 - Posted 2013-08-25 12:35:39 »

I recall that launch4j never worked for me because I dont use fat jars

Offline Z-Man
« Reply #24 - Posted 2013-08-25 17:54:21 »

I recall that launch4j never worked for me because I dont use fat jars
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?

... snip ...

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.
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.
Offline Jeremy
« Reply #25 - Posted 2013-08-25 19:38:25 »

I recall that launch4j never worked for me because I dont use fat jars
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?

... snip ...

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.
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.)

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline BoBear2681

JGO Coder


Medals: 18



« Reply #26 - Posted 2013-08-25 23:17:20 »

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.

In short, you have lots of options!
Offline Cero
« Reply #27 - Posted 2013-08-26 02:22:36 »

your games name instead of javaw.exe

when you package a jre, which you should, just change the exe name for example

Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #28 - Posted 2013-08-30 21:13:51 »

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.

Arcade swarm
Board Chess - Checkers - Othello
Offline Jeremy
« Reply #29 - Posted 2013-08-30 21:27:15 »

but I'm currently stuck trying to include a jre in the build. Any ideas?
What is the problem in particular?

The C++ stub still requires the JRE to be installed in some form or way (usually packaged with the executable.)

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (8 views)
2014-07-30 21:08:39

Riven (20 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!