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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
|
/**
* @(#) GL4JInst.java
* @(#) author: Ronald B. Cemer, Sven Goethel
* @(#) copyright: Copyright (c) 1999 Ronald B. Cemer under GNU GPL
* @(#) version: 2.00
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.zip.*;
import java.lang.reflect.*;
public class GL4JInst
extends Applet
implements Runnable, WindowListener, ActionListener
{
boolean isAnApplet = true;
URL codeBase = null;
static private final String gl4javaWWW =
"http://www.jausoft.com/Files/Java/1.1.X/GL4Java/Installer";
static private final String version = "2.04";
static private final String cannot_install_title =
"Cannot install GL4Java";
static private final String gl4java_not_installed_string =
"*** GL4Java INSTALLATION HAS FAILED ***";
// Status display:
private TextArea statustextarea = null;
// Popup window:
private Frame errorframe = null;
private TextArea errortextarea = null;
private Button errorokbutton = null;
Button bFinish = null;
// Misc:
private Thread myThread = null;
private String archive = null;
private String gl4j_archive = null;
private String glutfont_archive = null;
private boolean install_opengl = false;
private String opengl_archive = null;
private String png_archive = null;
private String gl_lib = null;
private String glu_lib = null;
private Vector lib_dir_list = null;
private String targetDirs[] = null;
private URL gl4javaURL = null;
private URL sourceURL = null;
private boolean initfailed = false;
private String initfailedreason = null;
private String tryrefresh = new String("");;
private MachineCtrl mctrl = null;
private String errstr = null;
boolean ok=true;
FilelistOS osFileLists = null;
FilelistWin95I386OpenGL osFileWin95OpenGL = new FilelistWin95I386OpenGL();
FilelistGL4JClasses fileGL4JClasses= new FilelistGL4JClasses();
FilelistGL4JArchiv fileGL4JArchiv= new FilelistGL4JArchiv();
FilelistGLUTFontClasses fileGLUTFontClasses= new FilelistGLUTFontClasses();
FilelistGLUTFontArchiv fileGLUTFontArchiv= new FilelistGLUTFontArchiv();
FilelistPNGClasses filePNGClasses= new FilelistPNGClasses();
FilelistPNGArchiv filePNGArchiv= new FilelistPNGArchiv();
/* Initialize the applet */
public void init()
{
// Create the status text area.
setLayout(new BorderLayout());
statustextarea = new TextArea();
statustextarea.setEditable(false);
statustextarea.setLocation(0,0);
statustextarea.setSize(getSize().width,getSize().height);
add("Center", statustextarea);
if(!isAnApplet)
{
bFinish = new Button("Quit");
bFinish.setActionCommand("quit");
bFinish.addActionListener(this);
add("South", bFinish);
try {
String current_dir = System.getProperty("user.dir");
if(current_dir!=null)
{
current_dir=current_dir.replace('\\','/');
if(!current_dir.endsWith("/"))
current_dir=current_dir+"/";
if(!current_dir.startsWith("/"))
current_dir="/"+current_dir;
codeBase = new URL ("file://"+current_dir);
gl4javaURL = new URL (gl4javaWWW);
}
} catch (Exception e) {
System.out.println("could not convert the current directory to a code-base !\n"+e);
}
} else {
codeBase = getCodeBase();
}
mctrl = new MachineCtrl("GL4Java Installation");
ok = mctrl.isError()==false;
if(!ok)
{
errstr=mctrl.errstr;
statustextarea.setText
(statustextarea.getText() + errstr +"\n");
return;
}
}
public void start()
{
if (!ok)
{
statustextarea.setText
(statustextarea.getText() + mctrl.errstr +"\n");
return;
}
mctrl.enablePrivilege();
if(mctrl.isError())
{
statustextarea.setText
(statustextarea.getText() + mctrl.errstr +"\n");
mctrl.clearError();
}
mctrl.fetchPrivilegedInfos();
if(mctrl.isError())
{
statustextarea.setText
(statustextarea.getText() + mctrl.errstr +"\n");
mctrl.clearError();
}
osFileLists = FilelistTool.GetMyInstance(mctrl);
if(osFileLists==null)
{
statustextarea.setText
(statustextarea.getText() +
"No Package Found for:\n"+
"Java VM vendor is: " + mctrl.jvmVendor + "\n" +
"OS: "+
mctrl.osName+" "+mctrl.osVersion+" "+mctrl.osArch+"\n");
ok=false;
} else {
String[] descrText = {
"GL4Java Installer Version "+ getAppletInfo(),
"GL4Java Classes Version "+FilelistGL4JClasses.version,
"GL4Java Native-Libs Version "+osFileLists.getVersion(),
"------------------------------------------------------------"};
mctrl.machineOptionWindow(this, descrText, "Start Installation",
(isAnApplet==true)?this:null);
if(mctrl.isError())
{
statustextarea.setText
(statustextarea.getText() + mctrl.errstr +"\n");
mctrl.clearError();
}
}
}
public void startInstallation()
{
if (!ok)
{
statustextarea.setText
(statustextarea.getText() + mctrl.errstr +"\n");
return;
}
osFileLists = FilelistTool.GetMyInstance(mctrl);
if(osFileLists==null)
{
statustextarea.setText
(statustextarea.getText() +
"No Package Found for:\n"+
"Java VM vendor is: " + mctrl.jvmVendor + "\n" +
"OS: "+
mctrl.osName+" "+mctrl.osVersion+" "+mctrl.osArch+"\n");
ok=false;
}
myThread = new Thread(this);
myThread.start();
}
public void stop()
{
// Don't stop until we're done.
while (myThread != null)
{
try
{
Thread.currentThread().sleep(100);
}
catch (Exception e)
{ }
}
}
public void destroy()
{
}
public String getAppletInfo()
{
return version + " (c) 1999 Ronald B. Cemer & Sven Goethel";
}
public String[][] getParameterInfo()
{
String s[][] =
{
{ "sourcedir", "URL", "directory containing installable files (overrides default zip files)" },
};
return s;
}
/* This is the run() method of the
thread which does the actual work. */
public void run()
{
if(ok)
{
Cursor oldCursor = getCursor();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
// Initialize values for replaceable strings.
statustextarea.setText
(statustextarea.getText() +
"GL4Java Installer Version "+ getAppletInfo()+"\n"+
"GL4Java Classes Version "+FilelistGL4JClasses.version+"\n"+
"GL4Java Native-Libs Version "+osFileLists.getVersion()+"\n\n");
// Check for existence of GL and GLU libraries.
String fixstring = "";
lib_dir_list = new Vector();
if (mctrl.isWin32)
{
gl_lib = "OPENGL32.DLL";
glu_lib = "GLU32.DLL";
if (mctrl.os_lib_dir != null)
lib_dir_list.addElement(new String(mctrl.os_lib_dir));
fixstring =
"\n" +
"\n" +
"If you are running the first release of Windows 95, your\n" +
"system may not have OpenGL functionality. You can download\n" +
"OpenGL from the following URL:\n" +
" ftp://ftp.microsoft.com/softlib/MSLFILES/OPENGL95.EXE\n" +
"Be sure to save the file to an empty directory, then extract\n" +
"its contents using WinZip or another zip extractor, then copy\n" +
"the OPENGL32.DLL and GLU32.DLL files into your WINDOWS\\SYSTEM\n" +
"directory. Then return to this web page and run the GL4Java\n" +
"installation again.\n" +
"\n" +
"If you are running NT 4.0, you must have Service Pack 3 or\n" +
"later installed in order for your system to support OpenGL.\n" +
"NT 4.0 service packs can be downloaded from:\n" +
" www.microsoft.com/downloads\n";
}
else if (mctrl.isMacOs)
{
// TODO !!!
gl_lib = "GL.DLL";
glu_lib = "GLU.DLL";
if (mctrl.os_lib_dir != null)
lib_dir_list.addElement(new String(mctrl.os_lib_dir));
fixstring =
"\n" +
"\n" +
"Your system does not appear to have OpenGL functionality.\n" +
"You can download OpenGL for the Macintosh from the following URL:\n" +
" http://www.apple.com/opengl/\n" +
"Follow their installation instructions to install OpenGL.\n" +
"Then return to this web page and run the GL4Java installation\n" +
"again.";
}
else if (mctrl.isUnix)
{
gl_lib = "libGL.so";
glu_lib = "libGLU.so";
lib_dir_list.addElement(new String("/lib"));
lib_dir_list.addElement(new String("/usr/lib"));
lib_dir_list.addElement(new String("/usr/X11/lib"));
lib_dir_list.addElement(new String("/usr/X11R6/lib"));
lib_dir_list.addElement(new String("/usr/local/lib"));
fixstring =
"\n" +
"\n" +
"Your system does not appear to have OpenGL functionality.\n" +
"You can probably find a version of Mesa3D (a free OpenGL\n" +
"clone) at the following URL:\n" +
" http://www.mesa3d.org/\n" +
"Follow their installation instructions to install Mesa3D.\n" +
"Then return to this web page and run the GL4Java installation\n" +
"again.";
}
if ( (ok)
&& (gl_lib != null)
&& (gl_lib.length() > 0)
&& (lib_dir_list != null)
&& (lib_dir_list.size() > 0) )
{
if (!FileTool.libraryExists(mctrl,gl_lib,lib_dir_list))
{
if (mctrl.isWin95)
install_opengl = true;
else
{
ok = false;
statustextarea.setText
(statustextarea.getText() +
cannot_install_title+"\n"+
"GL4Java cannot be installed because\n" +
"the OpenGL library:\n" +
" " + gl_lib + "\n" +
"cannot be found." + fixstring);
return;
}
}
}
if ( (ok)
&& (glu_lib != null)
&& (glu_lib.length() > 0)
&& (lib_dir_list != null)
&& (lib_dir_list.size() > 0) )
{
if (!FileTool.libraryExists(mctrl,glu_lib,lib_dir_list))
{
if (mctrl.isWin95)
install_opengl = true;
else
{
ok = false;
statustextarea.setText
(statustextarea.getText() +
"GL4Java cannot be installed because\n" +
"the GLU library:\n" +
" " + glu_lib + "\n" +
"cannot be found." + fixstring);
return;
}
}
}
setCursor(oldCursor);
}
if (ok)
{
statustextarea.setText
(statustextarea.getText() +
"done.\n" +
"Java VM vendor is: " + mctrl.jvmVendor + "\n" +
"OS: "+
mctrl.osName+" "+mctrl.osVersion+" "+mctrl.osArch+"\n");
statustextarea.setText
(statustextarea.getText() +
"Classes will be installed to: " +
mctrl.browser_classes + "\n");
statustextarea.setText
(statustextarea.getText() +
"Native libraries will be installed to: " +
mctrl.browser_natives +"\n");
if (mctrl.isWin32)
{
if (mctrl.isWin95)
{
opengl_archive = osFileWin95OpenGL.getArchiv() ;
}
if(mctrl.isMicrosoftJvm)
{
gl4j_archive = fileGL4JClasses.getArchiv();
glutfont_archive = fileGLUTFontClasses.getArchiv();
png_archive = filePNGClasses.getArchiv();
} else {
gl4j_archive = fileGL4JArchiv.getArchiv();
glutfont_archive = fileGLUTFontArchiv.getArchiv();
png_archive = filePNGArchiv.getArchiv();
}
} else {
gl4j_archive = fileGL4JArchiv.getArchiv();
glutfont_archive = fileGLUTFontArchiv.getArchiv();
png_archive = filePNGArchiv.getArchiv();
}
archive = osFileLists.getArchiv();
// Install OpenGL if needed.
if ( ok
&& (install_opengl)
&& (opengl_archive != null)
&& (opengl_archive.length() > 0) )
{
if(!isAnApplet && !FileTool.fileExists(mctrl, opengl_archive))
{
statustextarea.setText
(statustextarea.getText() +
"Getting File(s): OpenGL for Win95\n");
ok = FileTool.copyFileFromDir(mctrl,
gl4javaURL,
opengl_archive, opengl_archive,
statustextarea);
}
if(ok)
{
statustextarea.setText
(statustextarea.getText() +
"Install OpenGL for Win95\n");
try
{
sourceURL = new URL(codeBase,opengl_archive);
}
catch (Exception e)
{
ok=false;
statustextarea.setText
(statustextarea.getText() +
"File does not exist: "+codeBase+","+opengl_archive+" !\n");
}
}
if(ok)
{
targetDirs = new String[1];
targetDirs[0] = mctrl.os_lib_dir;
ok = FileTool.copyFilesFromZip
(mctrl, sourceURL, targetDirs, statustextarea);
}
}
// Now install the GL4Java files.
if ( ok
&& (gl4j_archive != null)
&& (gl4j_archive.length() > 0) )
{
if(!isAnApplet && !FileTool.fileExists(mctrl, gl4j_archive))
{
statustextarea.setText
(statustextarea.getText() +
"Getting File(s): GL4Java Java Classes\n");
ok = FileTool.copyFileFromDir(mctrl,
gl4javaURL,
gl4j_archive, gl4j_archive,
statustextarea);
}
if(ok)
{
statustextarea.setText
(statustextarea.getText() +
"Install GL4Java Java Classes\n");
try
{
sourceURL = new URL(codeBase,gl4j_archive);
}
catch (Exception e)
{
ok=false;
statustextarea.setText
(statustextarea.getText() +
"File does not exist: "+codeBase+","+gl4j_archive+" !\n");
}
}
if(ok)
{
targetDirs = new String[1];
targetDirs[0] = mctrl.browser_classes;
ok = FileTool.copyFilesFromZip
(mctrl, sourceURL, targetDirs,statustextarea);
}
}
if ( ok
&& mctrl.installGLUTFontSupport
&& (glutfont_archive != null)
&& (glutfont_archive.length() > 0) )
{
if(!isAnApplet && !FileTool.fileExists(mctrl, glutfont_archive))
{
statustextarea.setText
(statustextarea.getText() +
"Getting File(s): GL4Java GLUT-FONT Java Classes\n");
ok = FileTool.copyFileFromDir(mctrl,
gl4javaURL,
glutfont_archive, glutfont_archive,
statustextarea);
}
if(ok)
{
statustextarea.setText
(statustextarea.getText() +
"Install GL4Java GLUT-FONT Java Classes\n");
try
{
sourceURL = new URL(codeBase,glutfont_archive);
}
catch (Exception e)
{
ok=false;
statustextarea.setText
(statustextarea.getText() +
"File does not exist: "+codeBase+","+glutfont_archive+" !\n");
}
}
if(ok)
{
targetDirs = new String[1];
targetDirs[0] = mctrl.browser_classes;
ok = FileTool.copyFilesFromZip
(mctrl, sourceURL, targetDirs,statustextarea);
}
}
if ( ok
&& (png_archive != null)
&& (png_archive.length() > 0) )
{
if(!isAnApplet && !FileTool.fileExists(mctrl, png_archive))
{
statustextarea.setText
(statustextarea.getText() +
"Getting File(s): PNG Java Classes\n");
ok = FileTool.copyFileFromDir(mctrl,
gl4javaURL,
png_archive, png_archive,
statustextarea);
}
if(ok)
{
statustextarea.setText
(statustextarea.getText() +
"Install PNG Java Classes\n");
try
{
sourceURL = new URL(codeBase,png_archive);
}
catch (Exception e)
{
ok=false;
statustextarea.setText
(statustextarea.getText() +
"File does not exist: "+codeBase+","+png_archive+" !\n");
}
}
if(ok)
{
targetDirs = new String[1];
targetDirs[0] = mctrl.browser_classes;
ok = FileTool.copyFilesFromZip
(mctrl, sourceURL, targetDirs,statustextarea);
}
}
if ( ok
&& (archive != null)
&& (archive.length() > 0) )
{
if(!isAnApplet && !FileTool.fileExists(mctrl, archive))
{
statustextarea.setText
(statustextarea.getText() +
"Getting File(s): GL4Java Native Libs\n");
ok = FileTool.copyFileFromDir(mctrl,
gl4javaURL,
archive, archive,
statustextarea);
}
if(ok)
{
statustextarea.setText
(statustextarea.getText() +
"Install GL4Java Native Libs\n");
try
{
sourceURL = new URL(codeBase,archive);
}
catch (Exception e)
{
ok=false;
statustextarea.setText
(statustextarea.getText() +
"File does not exist: "+codeBase+","+archive+" !\n");
}
}
if(ok)
{
targetDirs = new String[1];
targetDirs[0] = mctrl.browser_natives;
ok = FileTool.copyFilesFromZip
(mctrl, sourceURL, targetDirs,statustextarea);
}
}
} else {
statustextarea.setText
(statustextarea.getText() +
"GL4Java cannot be installed because\n" +
"your combination of browser, Java Virtual\n" +
"Machine and operating system may not currently.\n" +
"supported.\n" +
"\n" +
"Operating system: " + mctrl.osName + "\n" +
"Java VM vendor..: " + mctrl.jvmVendor + "\n" +
gl4java_not_installed_string);
}
statustextarea.setText
(statustextarea.getText() +
(ok==false ? "*** INSTALLATION FAILED ***\n" : "done.\n"));
if (ok)
{
statustextarea.setText
(statustextarea.getText() +
"The GL4Java libraries have been\n" +
"successfully installed on your\n" +
"system.\n" +
"\n" +
"Please restart your browser!\n"+
"\n" +
"You should now be able to run 3D web\n" +
"applets which use GL4Java.");
if(isAnApplet)
showStatus("Installation complete! Please restart your browser!");
} else if(isAnApplet)
showStatus("Installation failed!");
myThread = null;
}
public void windowActivated(WindowEvent e)
{
}
public void windowClosed(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowOpened(WindowEvent e)
{
}
/* ActionListener methods used to kill errorframe and its contents: */
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("quit"))
{
stop();
if(myThread == null && !isAnApplet)
if(mctrl!=null && mctrl.dialog==null)
System.exit(0);
}
if (e.getActionCommand().equals("Start Installation"))
{
if(mctrl.dialog!=null)
{
mctrl.dialog.setVisible(false);
mctrl.dialog.dispose();
mctrl.dialog=null;
}
startInstallation();
}
}
public static void main( String args[] )
{
Frame mainFrame = new Frame("GL4Java Installation");
GL4JInst applet = new GL4JInst();
applet.isAnApplet=false;
applet.setSize(400, 600);
applet.init();
applet.start();
mainFrame.add(applet);
mainFrame.pack();
mainFrame.setVisible(true);
}
}
|