Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (427)
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  
  WebStart, VM options & J2D  (Read 7090 times)
0 Members and 1 Guest are viewing this topic.
Offline CommanderKeith
« Posted 2006-06-17 05:37:16 »

Hi,

I want to be able to set some of these:
-Dsun.java2d.translaccel=true
-Dsun.java2d.ddforcevram=true
-Dsun.java2d.opengl=True

but WebStart doesn't let you, it only allows those given here: http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources

Before using WebStart I have been using System.exec(...) to restart a new VM with options however this doesn't work with WebStart since I can't find where the bin/java.exe file is.  How can you set these options from WebStart?  The JOGL guys must do it somehow since they need to set -Dsun.java2d.opengl=True.  But how?

Thanks,
Keith

PS: Below is the code I used to use that no longer works with WebStart

   public static void executeOptionedVM(boolean enableServerVM,
                              boolean enableOpenGL,
                              boolean enableCMSGC,
                              boolean enableDDScale,
                              boolean enableLargeMaxHeap,
                              boolean enableTranslAccel,
                              boolean enableDDForceVRAM,
                              boolean enableNoddraw) throws java.io.IOException, SecurityException{
               String fileSeparator = System.getProperty("file.separator");
               String classPathOption = "-classpath"+" "+"\""+System.getProperty("java.class.path")+"\"";
               // the above is the problem, it returns deploy.jar in WebStart, not the actual classpath

               System.out.println("System.getProperty(java.class.path)"+System.getProperty("java.class.path"));

               String serverVMOption = "-server";
               String openGLOption = "-Dsun.java2d.opengl=True";
               String cmsGCOption = "-XX:+UseConcMarkSweepGC";
               String ddScale = "-Dsun.java2d.ddscale=true";
               String largeMaxHeap = "-Xmx128m";
               String translAccel = "-Dsun.java2d.translaccel=true";
               String ddForceVRAM = "-Dsun.java2d.ddforcevram=true";
               String noddraw = "-Dsun.java2d.noddraw=true";

               String commandString = System.getProperty("java.home")+fileSeparator+"bin"+fileSeparator+"java.exe"+" ";
               if (enableServerVM){
                  commandString += serverVMOption+" ";
               }
               if (enableOpenGL){
                  commandString += openGLOption+" ";
               }
               if (enableCMSGC){
                  commandString += cmsGCOption+" ";
               }
               if (enableDDScale){
                  commandString += ddScale+" ";
               }
               if (enableLargeMaxHeap){
                  commandString += largeMaxHeap+" ";
               }
               if (enableTranslAccel){
                  commandString += translAccel+" ";
               }
               if (enableDDForceVRAM){
                  commandString += ddForceVRAM+" ";
               }
               if (enableNoddraw){
                  commandString += noddraw+" ";
               }

               String fullClassName = Main.class.getCanonicalName();
               commandString += classPathOption+" "+fullClassName+" "+noOptions;

               System.out.println(commandString);

               System.out.println("about to launch new VM with options");

               Runtime.getRuntime().exec(commandString);
   }

Offline CommanderKeith
« Reply #1 - Posted 2006-06-18 23:48:44 »

Basic question:
Can WebStart set (non-standard) Java2D options? (ie, options besides noddraw)
If not, is there a hack, similar to the code above?

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 70
Projects: 15


★★★★★


« Reply #2 - Posted 2006-06-19 00:10:04 »

this isn't exactly a hack but some of the options can be set in your app instead of the java web start using something like

1  
System.setProperty("Dsun.java2d.translaccel", "true");


however doesn't work for all types of options but should be ok for most
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CommanderKeith
« Reply #3 - Posted 2006-06-19 00:26:05 »

Cheers kapta  Cool.

I thought that most of those kind of options had to be set at the outset, for example when you set the OGL pipeline it has to be done before any directdraw has happened.

Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #4 - Posted 2006-06-19 02:27:17 »

It would be wise to put the System.setProperty stuff in the main method rather than say in the paint method before anything actually paints; you never know what might happen with initilisation and the like...

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #5 - Posted 2006-06-19 03:40:10 »

A static initializer block in the main class is the earliest you can run any of your applications code.  I usually put code that sets flags like that there.

Offline CommanderKeith
« Reply #6 - Posted 2006-06-19 06:16:58 »

Thanks a lot for the help.  By the way, I'm a little in awe at how you all know that you can set flags using System.setProperty(String, String)?

The API docs http://java.sun.com/j2se/1.5.0/docs/api/ for System drop only a very feint hint that you can do it (and its in the class description, not in the setProperty method).  I can't believe that I've been using the above hack for so long!  Tongue  It really sucked because I had to wait for two VM's to load!  This is at least 100 times better  Cheesy

Many thanks,
Keith

Online Riven
« League of Dukes »

JGO Overlord


Medals: 612
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #7 - Posted 2006-06-19 09:12:55 »

AFAIK the UI is loaded previous to the main-class static-block, as the webstart UI is already loaded.

Launching a new VM with the proper flags might be the only way.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline CommanderKeith
« Reply #8 - Posted 2006-06-20 10:23:31 »

AFAIK the UI is loaded previous to the main-class static-block, as the webstart UI is already loaded.

Launching a new VM with the proper flags might be the only way.

I hope you're wrong   Smiley.  My guess is that WebStart doesn't load the UI since the loading screen has a Windows look & feel and not Swing's default Ocean.  Perhaps its a native dialog?  Loading look&feels takes too long anyway, I doubt that webstart would waste the time.  Besides, how could JOGL apps that are combined with Swing use WebStart when they need to turn on J2D's openGL pipeline? 

Also Chet Haase prescribes it here: http://weblogs.java.net/blog/chet/archive/2004/09/index.html

You can play with the OpenGL implementation by passing in a command-line argument to tell us to enable it:

   java -Dsun.java2d.opengl=true
or you can set the same system property in your main() method:

   System.setProperty("sun.java2d.opengl", "true");


As soon as I can get my stupid server mime.type fixed I'll try the above with WebStart and report back for anyone interested.

Thanks,
Keith

Offline c_lilian

Senior Member


Projects: 1


Java games will probably rock someday...


« Reply #9 - Posted 2006-06-20 10:30:14 »

Hi,

I want to be able to set some of these:
-Dsun.java2d.translaccel=true
-Dsun.java2d.ddforcevram=true
-Dsun.java2d.opengl=True

but WebStart doesn't let you, it only allows those given here: http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources


You CAN set these properties in your jnlp file when your application is signed (<security><all-permissions/></security>).
This limitation is only for untrusted application.

Lilian Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CommanderKeith
« Reply #10 - Posted 2006-06-20 10:48:46 »

Thanks  Lilian  Smiley

I think I'll go with the System.setProperty(...) anyway so the plain old jar will work on its own.

Offline c_lilian

Senior Member


Projects: 1


Java games will probably rock someday...


« Reply #11 - Posted 2006-06-20 10:56:47 »

As you want

(but remember System.setProperty() also requires signing as you're touching secured properties, so you'll have to sign your jar anyway.)


Lilian Smiley

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #12 - Posted 2006-06-22 23:39:27 »

AFAIK the UI is loaded previous to the main-class static-block, as the webstart UI is already loaded.

Launching a new VM with the proper flags might be the only way.

Off the top of my head ... doesn't webstart do some smart stuff with launching the app in fresh classloaders and fresh system resources (including graphics) ?

malloc will be first against the wall when the revolution comes...
Offline CommanderKeith
« Reply #13 - Posted 2006-07-09 03:34:13 »

It seems like Riven was right.  WebStart isn't honouring the J2D System property options I'm setting from the main class's static initialisation block.   Sad What a bugger.  That means I'll have to set them from the jnlp file which sucks because then I'll need to

enable one set of options when they're not ideal or
have multiple copies of my game's jnlp file posted on the website which have the different options

Can anybody think of a way to get around it?  Even a way to start another VM would be OK.  My way above doesn't work with WebStart (or with a non-windows box).

Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #14 - Posted 2006-07-09 11:48:41 »

What a bugger.

Well I wouldn't call it a bug, webstart simply loads AWT before your program starts, its the same as with applets.

lg Clemens
Offline CommanderKeith
« Reply #15 - Posted 2006-07-09 13:12:19 »

What a bugger.

Well I wouldn't call it a bug, webstart simply loads AWT before your program starts, its the same as with applets.

lg Clemens

Hehe, you're right, I didn't mean it like that Smiley.  Bugger is colloquial in Australian.  Its kind of like saying 'what a bummer' or 'darn'.  Wink

Offline campbell

Junior Member




Java games rock!


« Reply #16 - Posted 2006-07-09 17:56:56 »

In Mustang we added a number of additional system properties to the "secure" list:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6250769

This includes 2D-specific flags like:
  sun.java2d.opengl
  sun.java2d.d3d

Unfortunately, it appears that the developer's guide wasn't updated accordingly for Mustang to mention these new properties:
http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html

So I just filed a doc bug on Java Web Start so that they update that document properly (this bug should be visible tomorrow):
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6447014

As folks have discovered already in this thread, there's really no way to call System.setProperty() or similar and have the OGL/D3D flags take effect from within a Web Start application, since it's too late at that point.  So the only way to make these flags have an effect is to pass them from the JNLP file, as is now allowed in Mustang.

Chris
Offline CommanderKeith
« Reply #17 - Posted 2006-07-11 05:17:21 »

Thanks for the help Chris.

I notice that the following Windows options aren't in that 'secure' list:
sun.java2d.translaccel=true
sun.java2d.ddforcevram=true
sun.java2d.ddscale=true

2nd to the OGL option, these arguments provide the best J2D performance of all in Mustang (on my box).
Since d3d has less driver trouble than OGL, it would be great to put them on the safe list too.  Just a suggestion that probably will only help us gaming folks, but worth a try  Smiley.
Keith

Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #18 - Posted 2006-07-11 18:28:29 »

Bugger is colloquial in Australian.  Its kind of like saying 'what a bummer' or 'darn'.  Wink

*lol* ... I guess this comes from writing before thinking  ^^
However Australia is great *dreaming* :-)

lg Clemens
Offline CommanderKeith
« Reply #19 - Posted 2006-07-22 05:03:11 »

Does anyone know how to relaunch the VM programmatically? ie start a new VM from a running WebStarted VM?  I want to be able to relaunch my game with different J2D system properties.

If this can't be done then I'll have to have 3+ versions of my JNLP file: a default one, an openGL pipeline one & a fully-enabled directdraw version.  That would be bad, so any help is appreciated!

Thanks,
Keith


Offline Kova

Senior Member





« Reply #20 - Posted 2006-07-25 15:46:31 »

what do you mean 3 versions? If pipelines can't be abled programaticly you assume user will relaunch JVM? ...If so, maybe you can read what settings are set and run appropriate rendering engine.
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #21 - Posted 2006-07-25 19:22:52 »

Does anyone know how to relaunch the VM programmatically? ie start a new VM from a running WebStarted VM?  I want to be able to relaunch my game with different J2D system properties.

If this can't be done then I'll have to have 3+ versions of my JNLP file: a default one, an openGL pipeline one & a fully-enabled directdraw version.  That would be bad, so any help is appreciated!

Thanks,
Keith



You could probably use Runtime.exec() to launch a new VM process.
I haven't done this from a JWS app, though.

Something like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
          String classPath = System.getProperty("java.class.path",".") + " "; // this may need to be tweaked
         String opt = "-Dsun.java2d.d3d=true MyMegaApp"; // or whatever
         String cmd = new String(System.getProperty("java.home") +
                                  File.separator +
                                  "bin" +
                                  File.separator +
                                  "java -cp " + classPath +
                                  opt);
          try {
              childProc = Runtime.getRuntime().exec(cmd);
              childProc.waitFor();
          } catch (Exception e) {
              e.printStackTrace();
          }


Make sure you read stderror and stdout streams, otherwise your child
process will hang. Look around for samples on how to use Runtime.exec().

But really, I think that having 3 jnlp files isn't that bad an alternative, given that
you'll have two VMs running otherwise.

Thanks,
   Dmitri
Offline CommanderKeith
« Reply #22 - Posted 2006-07-26 02:18:22 »

But really, I think that having 3 jnlp files isn't that bad an alternative

I worry that having 3 versions of the same program will just confuse the user.  If only the programmatic System.setProperty() way of setting java2D flags worked with webstart, then yours & Chris C's awesome work on the OGL & directdraw/d3d pipelines could be unleashed!

String classPath = System.getProperty("java.class.path",".") + " "; // this may need to be tweaked

Thanks, I've got similar code that I put up earlier in this thread but the classpath doesn't come out properly in webstart, as you commented above.  I've been looking into how the classpath can be gotten from a webstarted app but it looks impossible since I can't find a way of telling where that jar file that contains the classes is stored... Also, Runtime.exec("bin/java.exe MyJar.jar") is platform specific, which is a pity.

Thanks for the help,
Keith

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #23 - Posted 2006-07-26 15:21:57 »

You could probably use Runtime.exec() to launch a new VM process.
I haven't done this from a JWS app, though.

Something like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
          String classPath = System.getProperty("java.class.path",".") + " "; // this may need to be tweaked
          String opt = "-Dsun.java2d.d3d=true MyMegaApp"; // or whatever
          String cmd = new String(System.getProperty("java.home") +
                                  File.separator +
                                  "bin" +
                                  File.separator +
                                  "java -cp " + classPath +
                                  opt);
          try {
              childProc = Runtime.getRuntime().exec(cmd);
              childProc.waitFor();
          } catch (Exception e) {
              e.printStackTrace();
          }


Never ever use the single argument version of Runtime.exec().
You are bound to make assumptions about how the arguments are split based on the shell you use, but Runtime.exec(cmd) is not a shell and does not parse arguments the same way.  If there was a space in the "java.home" path or "java.class.path"... which there usually is on Windows (e.g. "C:\ Program Files\...") then the version used above will fail miserably.

Use the version of Runtime.exec that takes an array for the arguments.  It's much safer.

Offline CommanderKeith
« Reply #24 - Posted 2006-09-13 05:15:06 »

Hi Dmitri and Chris,

We need a way to know what Java2D options will be the fastest (default vs noddraw vs opengl).  Also, we need a way to switch VM options programmatically even after Web Start has launched (ie a System.setProperty(...) thing that is actually honoured).  The reason is that Java2D does have the performance to make a game run fast, but the VM options are crucial to squeezing the most out.  I've trialled my game on lots of different computers and had the following results, which vary a lot depending on the options.

On crap or non-video card computers (~2GHz processor) my game runs at 2 FPS with no options.  In noddraw mode it runs at about 15 FPS.  On good computers with good video cards or fast processors opengl-pipeline mode & also the noddraw mode run at between 40-70FPS.  The game is here: http://www.freewebs.com/commanderkeith/STG.jnlp

Can you work out a way to set the VM options programmatically and/or a way to work out which one is best?  A work around would be a way to relaunch the VM but that can't be done with WebStart & its caching as far as i can tell.

Thanks,
Keith

Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #25 - Posted 2006-09-15 07:51:24 »

Do you mean, for now or for future release?

Unfortunately currently I don't think there's a single option which would
work everywhere consistently because of so many variables involved
(what the game does, cpu, video board, driver) - except for may be for the
noddraw=true - it's pretty consistent in the sense that the faster the system's CPU
the faster your game will run.

So if the lowest denominator is 15fps and it's acceptable, I would
suggest using the noddraw mode.

Has it already been suggested having separate jnlp files for each
configuration (with opengl, d3d or noddraw)? I agree that it ain't pretty,
and opengl and d3d will only work on mustang (which confuses the matters
even more)..

As for future releases, I completely agree, we need some better
way of selecting the pipelines.

Thanks,
Dmitri
Offline CommanderKeith
« Reply #26 - Posted 2006-09-19 08:12:25 »


As for future releases, I completely agree, we need some better
way of selecting the pipelines.


Thanks for considering this problem.

As a work around for now, it would be good enough if there was a way to programmatically

1) re-launch the VM from within Web Start or
2) make WebStart honour the System.setProperty flags.

That way we could detect which mode was the best & try others if we want.  Currently, we can't even re-launch our game with a new (optioned) VM since Runtime.exec(...) can't be given the jar file of our game because (as far as I know) Web Start caches it in a black hole  Angry.  I know Web Start isn't your field, but its holding us back from showing off how good Java2D can be.  Maybe you could have a word with the deployment guys?

Many thanks,
Keith

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 (78 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (221 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!