Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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  
  Removed..  (Read 1266 times)
0 Members and 1 Guest are viewing this topic.
Offline NewOnJava

Junior Devvie




1970 born Java game hobbyer.


« Posted 2008-09-05 16:22:30 »

Removed..
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 830
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2008-09-05 16:40:01 »

Welcome to the horrible world of Applets.


It took me about 2 months to get the failrate of ~50% down to ~33% in an Applet for a company.

And that failrate is on systems that have Java installed.
I have a database full of statistics of:
 - Applets that are not launched
 - Applets that launch, but never reach init()
 - Applets that cannot connect to their own host (Firefox -> AccessControlException, I have a workaround posted on this forum)
 - Applets that crash on creating a translucent image for that stupid ORANGE preloader
 - Applets in deadlock 20% of the time, before my code is even executed, when inserting the applet dynamically by DOM manipulation




So... you might want to reconsider doing your project as an Applet.



Anyway, a bit of PHP code with 'least failures' .. Cry to get you started.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
function embedAppletObject($id, $w, $h, $mainClass, $codebase, $archive, $params=Array(), $forceLegacy=false)
{
$legacyCode = <<<EOT
     
   <applet id="{$id}"
      CODEBASE="{$codebase}"
      ARCHIVE="${archive}"
      CODE="{$mainClass}"
      WIDTH="{$w}"
      HEIGHT="{$h}"
      MAYSCRIPT="true">
     
EOT;
$legacyCodeClose = '</applet>';

//

$msie6and7Code = <<<EOT
     
<object id="{$id}"
  classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
  codebase="./downloads/java-latest.exe"
  width="{$w}" height="{$h}">
 
  <param name="code"       value="{$mainClass}">
  <param name="codebase"   value="{$codebase}">
  <param name="archive"    value="{$archive}">
 
EOT;

$msie6and7CodeClose = '</object>';

//

$firefox2Code = <<<EOT
     
<object id="{$id}"
  classid="java:{$mainClass}"
  codebase="{$codebase}"
  archive="{$archive}"
  type="application/x-java-applet"
  width="{$w}" height="{$h}">
     
EOT;

$firefox2CodeClose = '</object>';

//

$firefox3Code      = $legacyCode;
$firefox3CodeClose = $legacyCodeClose;

$bestEffortCode      = $msie6and7Code;
$bestEffortCodeClose = $msie6and7CodeClose;

//

   $browserName = browserName();
   $openTag = '';
   $closeTag = '';
   
   if($forceLegacy)
   {
      $openTag  = $legacyCode;
      $closeTag = $legacyCodeClose;
   }  
   else if($browserName=='MSIE')
   {
      $openTag  = $msie6and7Code;
      $closeTag = $msie6and7CodeClose;
   }
   else if($browserName=='Firefox')
   {
      if(isVersionLess(browserVersion(), '3.0.0.0'))
      {
         $openTag  = $firefox2Code;
         $closeTag = $firefox2CodeClose;
      }
      else
      {
         $openTag  = $firefox3Code;
         $closeTag = $firefox3CodeClose;
      }
   }
   else
   {
      $openTag  = $bestEffortCode;
      $closeTag = $bestEffortCodeClose;
   }
   
   $out = $openTag;  
   foreach($params as $name => $value)
      $out .= '<param name="'.$name.'" value="'.$value.'">'."\r\n";      
   $out .= $closeTag;
   
   return $out;
}

function indexOf($text, $find)
{
   $pos = strpos($text, $find);
   if($pos === false)
      return -1;
   return $pos;
}

function after($text, $find)
{
   $index = indexOf($text, $find);
   if($index == -1) return null;  
   return substr($text, $index += strlen($find));
}

function before($text, $find)
{
   $index = indexOf($text, $find);
   if($index == -1) return null;  
   return substr($text, 0, $index);
}

function between($text, $pre, $post)
{  
   $ret = after($text, $pre);
   if($ret == null) return null;
   return before($ret, $post);
}
   
function browserName()
{
   $userAgent = $_SERVER['HTTP_USER_AGENT'];
   
   if(strpos($userAgent, "MSIE")    !== false)   return "MSIE";
   if(strpos($userAgent, "Firefox") !== false) return "Firefox";
   if(strpos($userAgent, "Opera")   !== false)   return "Opera";
   
   return "unknown";
}

function browserVersion()
{
   $userAgent = $_SERVER['HTTP_USER_AGENT'];
   $browser = browserName();

   if($browser == "MSIE")     return between($userAgent, 'MSIE ', ';');
   if($browser == "Firefox")   return after($userAgent, 'Firefox/');
   if($browser == "Opera")     return between($userAgent, 'Opera/', ' ');

   return "unknown";
}
// $cur >  $cmp ----> return > 0
// $cur == $cmp ----> return = 0
// $cur <  $cmp ----> return < 0
function compareVersion($cur, $cmp)
{
   $curParts = splitText($cur, '.');
   $cmpParts = splitText($cmp, '.');
   
   $curCount = count($cmpParts);
   $cmpCount = count($curParts);
   
   $mul = 100;
   
   $curValue = 0;
   $cmpValue = 0;
   
   for($i=0; $i < max($curCount, $cmpCount); $i++)
   {
      $curValue *= $mul;
      $cmpValue *= $mul;
     
      if($curParts[$i] < 0 || $curParts[$i] > $mul)
         throw new Exception('invalid version: '.$cur);
      if($cmpParts[$i] < 0 || $cmpParts[$i] > $mul)
         throw new Exception('invalid version: '.$cmp);
     
      if($i < $curCount) $curValue += $curParts[$i];
      if($i < $cmpCount) $cmpValue += $cmpParts[$i];
   }
   
   return $curValue - $cmpValue;
}

function isVersionGreater($cur, $cmp){return compareVersion($cur, $cmp)>0;}
function isVersionLess($cur, $cmp)   {return compareVersion($cur, $cmp)<0;}
function isVersionGreaterOrEqual($cur, $cmp){return compareVersion($cur, $cmp)>=0;}
function isVersionLessOrEqual($cur, $cmp)   {return compareVersion($cur, $cmp)<=0;}

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline bienator

Senior Devvie




OutOfCoffeeException


« Reply #2 - Posted 2008-09-05 18:09:24 »


And that failrate is on systems that have Java installed.
I have a database full of statistics of:
 - Applets that are not launched
 - Applets that launch, but never reach init()
 - Applets that cannot connect to their own host (Firefox -> AccessControlException, I have a workaround posted on this forum)
 - Applets that crash on creating a translucent image for that stupid ORANGE preloader
 - Applets in deadlock 20% of the time, before my code is even executed, when inserting the applet dynamically by DOM manipulation
I hope you took a week off and filed a bug report for each of them Wink

@NewOnJava
Applets improved a lot with java 6.10 (but there is still room left). The only tip I can give you to work around the most trouble is to develop for Java 6 update 10 (or later) only. (but this is of course not always possible)
e.g starting your applet out-of-proccess seems to contribute a lot to stability because old running JVM instances caused often not reproducible issues when you tried to resurrect them.

I 've written a computational grid monitoring applet for my university which does file IO, peer2peer networking and even uses the scenegraph project for hardware accelerated 2d (well it does not rely on it but it was a lot of fun to write it Wink) and I can't complain about its stability. (e.g i can hit reload as often I want - it restarts, reconnects etc seamlessly)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 830
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2008-09-05 18:20:00 »

Hm Smiley

I filed a few: "Cannot reproduce" was the default answer, 3-4 weeks later.
Many forums are littered with threads about people having major problems with applets.
But Sun "cannot reproduce" ... go figure.



Website target-audience: people interested in fully customizable furniture (down to the door handles and material of the left side of the 3rd drawer, etc).

They don't know what Java is (or don't care), you have to be grateful to find Java 1.4 and make the most of it. Asking the user to upgrade to 6u10, is like blocking everybody and their mother from your e-business. We have roughly 3-4 users per day that installed Java, according to the logs.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
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.

xFryIx (58 views)
2014-11-13 12:34:49

digdugdiggy (37 views)
2014-11-12 21:11:50

digdugdiggy (30 views)
2014-11-12 21:10:15

digdugdiggy (26 views)
2014-11-12 21:09:33

kovacsa (48 views)
2014-11-07 19:57:14

TehJavaDev (51 views)
2014-11-03 22:04:50

BurntPizza (51 views)
2014-11-03 18:54:52

moogie (66 views)
2014-11-03 06:22:04

CopyableCougar4 (65 views)
2014-11-01 23:36:41

DarkCart (150 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!