blib/script/java_server_install.pl untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 66 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use File::Spec::Functions;
2 use File::Copy;
3 use Socket qw(:crlf);
4  
5 print "This will attempt to install JavaServer.jar somewhere & then tell you$CRLF";
6 print "how to run it... hopefully!$CRLF";
7  
8 my $jhome = $ENV{JAVA_HOME};
9 my $line;
10 if ($jhome)
11 {
12 my $lib = File::Spec->catdir($jhome, "lib");
13 print "Cool - your JAVA_HOME environment variable is set to $jhome.$CRLF";
14 print "If you let me copy it into $lib it'll be easier to run.$CRLF";
15 print "Do I have permission to copy 'JavaServer.jar' to $lib? (Y/n)? ";
16 my $in = <STDIN>;
17 if ($in !~ /^n/i)
18 {
19 copy('JavaServer.jar', $lib);
20 $jar = $lib;
21 }
22 else
23 {
24 $jar = ".";
25 }
26  
27 my @classpath = map { File::Spec->catdir($lib, $_) }
28 qw(classes.zip swingall.jar swing.jar);
29 push @classpath, File::Spec->catdir($jar, 'JavaServer.jar');
30  
31 local($") = ":";
32 $line = "java -classpath @classpath com.zzo.javaserver.JavaServer$CRLF";
33  
34 my $OS = $^O;
35 if ($OS =~ /mswin/i)
36 {
37 open(O,">run_js.bat");
38 print O "$line";
39 close(O);
40 $f = ".bat";
41 }
42 else
43 {
44 open(O,">run_js.sh");
45 print O "#!/bin/sh$CRLF";
46 print O "$line";
47 close(O);
48 $f = ".sh";
49 chmod 0777,"run_js.sh";
50 }
51  
52 print "To run JavaServer type this line:$CRLF";
53 print "run_js${f}$CRLF";
54 }
55 else
56 {
57 my $cp = $ENV{CLASSPATH};
58 if ($cp)
59 {
60 print "Add the directory where 'JavaServer.jar' will sit to your$CRLF";
61 print "CLASSPATH environment variable and then type:$CRLF";
62 print "java JavaServer$CRLF";
63 print "to run JavaServer.$CRLF";
64 }
65 else
66 {
67 print "Yer gonna hafta hunt down your 'classes.zip' file as$CRLF";
68 print "well as 'swing.jar' and 'swingall.jar' if you want to$CRLF";
69 print "use Swing, and manually list all of those files including$CRLF";
70 print "the directories they're in on the 'java' command line like -$CRLF";
71 print "As well as putting JavaServer.jar someplace and then execute:$CRLF";
72 print "/path/to/java -classpath /path/to/classes.zip:/path/to/swing.jar:/path/to/swingall/jar:/path/to/JavaServer.jar JavaServer$CRLF";
73 print "to run JavaServer.$CRLF";
74 }
75 }
76