View Javadoc

1   package org.wcb.installs;
2   
3   import org.wcb.installs.OSSystem;
4   import java.util.Vector;
5   
6   public class WindowsSystem extends OSSystem{
7       
8       private static String homeInstallString = "C:"+SEP+"Program Files"+SEP+"alice";
9       private static String homeJarString = "C:"+SEP+"windows";
10      
11      /***
12       * Accessor to allow the user to specify the location
13       * they want to install the program binaries.
14       */
15      public void setInstallDirectory(String binDir){
16  	homeInstallString = binDir;
17      }
18  
19      /***
20       * Acessor to set the jar file location and check if
21       * the necessary jars exist in that directory.
22       */
23      public Vector setJarDirectory(String jarDir){
24  	homeJarString = jarDir;
25          return jarFilesExist(homeJarString);
26      }
27  
28      /***
29       * Takes the binary directory string and
30       * Starts creating the necessary directories so that
31       * files can be written into them.
32       */
33      public void makeFile(String homeBinString){
34  	if(!directoryExists(homeBinString)) {
35  	    if(!createNewDirectory(homeBinString)) 
36  		System.out.println("Failed to bin directory");
37  	    else {
38  		writeBatScript(homeBinString);	
39  		writeServerBatScript(homeBinString);
40  	    }
41  	} else {
42  	    writeBatScript(homeBinString);	  
43  	    writeServerBatScript(homeBinString);
44  	}
45      }
46  
47      private void writeBatScript(String homeBinString){
48  	StringBuffer sb = new StringBuffer("REM Alice bat file");
49  	sb.append(LINE_SEP+"\"");
50  	sb.append(System.getProperty("java.home")+SEP+"bin"+SEP+"java\" -classpath \"");
51  	sb.append("%CLASSPATH%;");
52  	sb.append(homeInstallString+SEP+"alice.jar\" ");	
53  	sb.append("org.wcb.autohome.Main %1 %2 %3 %4 %5 %6 %7 %8 %9"+LINE_SEP);	
54  	writeFile(sb.toString(), homeBinString+SEP+"jHome.bat");
55      }  
56  
57      private void writeServerBatScript(String homeBinString){
58  	StringBuffer sb = new StringBuffer("REM Alice Server bat file");
59  	sb.append(LINE_SEP+"\"");
60  	sb.append(System.getProperty("java.home")+SEP+"bin"+SEP+"java\" -classpath \"");
61  	sb.append("%CLASSPATH%;");
62  	sb.append(homeInstallString+SEP+"alice.jar\" ");	
63  	sb.append("org.wcb.autohome.JHomeServer "+homeInstallString+SEP+"alice.jar %1 %2 %3 %4 %5 %6 %7 %8 %9"+LINE_SEP);	
64  	writeFile(sb.toString(), homeBinString+SEP+"HAserver.bat");
65      }  
66      
67  }