Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Deployment: embedding Java VM in a game  (Read 1054 times)
0 Members and 1 Guest are viewing this topic.
Offline Grunnt

JGO Wizard


Medals: 59
Projects: 8
Exp: 5 years


Complex != complicated


« Posted 2012-09-04 09:22:53 »

Hey happy people @ JGO!

I've been looking around a bit for a good answer to this question, but I could not find it. I'd like to follow the prophesy of Cas, whom I quote completely out of context:
Quote
we don't care! We just want stuff to work.
Edit: make sure to listen to this to get in the right mood.

I also want stuff to work, and I don't mind if things are theoretically pure. Now I'm looking for a good way (i.e. one that "works") to deploy a Java game (using LWJGL) as a Windows executable that works whether or not the user has installed a JVM. In other words, I'd like to embed a JVM into an executable, but I'm not sure how to do this.

This is what I do know:

The Oracle JRE
According to the Oracle JRE readme it is perfectly normal to distribute the JRE alongside with your application:
Quote
The Java(TM) Platform, Standard Edition Runtime Environment (JRE(TM)), excluding the JavaFX(TM) runtime, is intended for software developers and vendors to redistribute with their applications.
I presume this is also true when I embed the JRE inside my executable. (after all, it's not much different from distributing it in a ZIP file)

How to make it small
Also in the JRE readme is a list of files that can be excluded. When I strip away most of these files, the JRE is still (compressed) 24MB. While that's not a huge problem, I'd like to reduce it in size further. One thing I'm thinking of is to keep on stripping stuff out until my game no longer works.. How would you guys do this?

Here's what I found so far:
  • Remove the optional files listed in the JRE readme (make sure to also remove the files that are used for the browser plugins).
  • Compress the rt.jar runtime library as described in this Oracle blog post.
  • Use an alternative JVM that has a small footprint, e.g. JamVM. As far as I understand, this may have severe performance implications however.

The embedding process
What tools can be used to embed a JRE? I know that launch4j has an "embed JRE" function, but I'm not sure what else is out there. What tools or approaches are best when embedding a JRE?

Thanks!

Offline 65K
« Reply #1 - Posted 2012-09-04 09:31:48 »

How to make it small
Also in the JRE readme is a list of files that can be excluded. When I strip away most of these files, the JRE is still (compressed) 24MB. While that's not a huge problem, I'd like to reduce it in size further. One thing I'm thinking of is to keep on stripping stuff out until my game no longer works.. How would you guys do this?
I just copy the complete JRE folder (plus server VM) into my game folder. Stripping anything apart from the listed files breaks the license agreement.
I don't embed the JRE but let the exe launch the game with the private JRE.

Online princec

JGO Kernel


Medals: 284
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2012-09-04 12:20:46 »

(@65k - That's what is generally meant by "embedding" the JRE)

launch4j and jsmooth are well known contenders for running Java apps with private JREs. I build my own launcher exes.

There will be a little turmoil ahead as Mac OS transitions to OpenJDK7 and I'll have to figure out the foibles of deploying that (it's not going to be straightforward - the games have to remain backwards compatible with OSX 10.5.8 and above as well, and LWJGL still doesn't work with OpenJDK7 on the Mac yet).

For Linux I will be shifting to embedded private JREs as well, if only for parity's sake. I strongly dislike the concept of systemwide Java. Fortunately with the recent spate of stunningly powerful malware using systemwide Java as the vector it may finally be coming to a head.

Cas Smiley

Pages: [1]
  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.

xsi3rr4x (73 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (79 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (80 views)
2014-04-14 15:48:38

tom_mai78101 (104 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!