1*cd519653SAndrew Rist /************************************************************** 2*cd519653SAndrew Rist * 3*cd519653SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cd519653SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cd519653SAndrew Rist * distributed with this work for additional information 6*cd519653SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cd519653SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cd519653SAndrew Rist * "License"); you may not use this file except in compliance 9*cd519653SAndrew Rist * with the License. You may obtain a copy of the License at 10*cd519653SAndrew Rist * 11*cd519653SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*cd519653SAndrew Rist * 13*cd519653SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cd519653SAndrew Rist * software distributed under the License is distributed on an 15*cd519653SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cd519653SAndrew Rist * KIND, either express or implied. See the License for the 17*cd519653SAndrew Rist * specific language governing permissions and limitations 18*cd519653SAndrew Rist * under the License. 19*cd519653SAndrew Rist * 20*cd519653SAndrew Rist *************************************************************/ 21*cd519653SAndrew Rist 22cdf0e10cSrcweir package installer; 23cdf0e10cSrcweir 24cdf0e10cSrcweir import java.net.URLDecoder; 25cdf0e10cSrcweir import java.io.*; 26cdf0e10cSrcweir import java.util.*; 27cdf0e10cSrcweir import java.util.zip.*; 28cdf0e10cSrcweir import java.awt.*; 29cdf0e10cSrcweir import java.awt.event.*; 30cdf0e10cSrcweir import javax.swing.*; 31cdf0e10cSrcweir import java.net.*; 32cdf0e10cSrcweir 33cdf0e10cSrcweir public class InstUtil { 34cdf0e10cSrcweir buildSversionLocation()35cdf0e10cSrcweir public static File buildSversionLocation() throws IOException { 36cdf0e10cSrcweir File theFile = null; 37cdf0e10cSrcweir StringBuffer str = new StringBuffer(); 38cdf0e10cSrcweir str.append(System.getProperty("user.home")); 39cdf0e10cSrcweir str.append(File.separator); 40cdf0e10cSrcweir StringBuffer thePath = new StringBuffer(str.toString()); 41cdf0e10cSrcweir 42cdf0e10cSrcweir String os = System.getProperty("os.name"); 43cdf0e10cSrcweir 44cdf0e10cSrcweir if (os.indexOf("Windows") != -1) { 45cdf0e10cSrcweir boolean bSVersionInHomeDir = new File(thePath.toString() + "sversion.ini").exists(); 46cdf0e10cSrcweir 47cdf0e10cSrcweir if (!bSVersionInHomeDir) { 48cdf0e10cSrcweir thePath.append("Application Data"); 49cdf0e10cSrcweir thePath.append(File.separator); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir theFile = findVersionFile(new File(thePath.toString())); 52cdf0e10cSrcweir } else if (os.indexOf("SunOS") != -1) { 53cdf0e10cSrcweir thePath.append(".sversionrc"); 54cdf0e10cSrcweir theFile = new File(thePath.toString()); 55cdf0e10cSrcweir } else if (os.indexOf("Linux") != -1) { 56cdf0e10cSrcweir thePath.append(".sversionrc"); 57cdf0e10cSrcweir theFile = new File(thePath.toString()); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir if (theFile == null) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?"); 63cdf0e10cSrcweir } 64cdf0e10cSrcweir if (!theFile.exists()) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?"); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir return theFile; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir 72cdf0e10cSrcweir hasNetbeansInstallation()73cdf0e10cSrcweir public static boolean hasNetbeansInstallation() { 74cdf0e10cSrcweir boolean result = false; 75cdf0e10cSrcweir try 76cdf0e10cSrcweir { 77cdf0e10cSrcweir result = checkForSupportedVersion( getNetbeansLocation(), versions ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir if (result == false) 80cdf0e10cSrcweir System.out.println("No supported version of NetBeans found."); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir catch ( IOException ioe ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir System.err.println("Exception caught trying to determine netbeans installation: " + ioe ); 85cdf0e10cSrcweir ioe.printStackTrace(); 86cdf0e10cSrcweir result = false; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir return result; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir checkForSupportedVersion( Properties installs, String[] supportedVersions )91cdf0e10cSrcweir private static boolean checkForSupportedVersion( Properties installs, String[] supportedVersions ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir if ( installs != null ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir for ( int index = 0; index < supportedVersions.length; index++ ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir String key = supportedVersions[ index ]; 98cdf0e10cSrcweir String path = null; 99cdf0e10cSrcweir if ( ( path = installs.getProperty(key) ) != null ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir // at least one supported version for netbeans present, so return; 102cdf0e10cSrcweir return true; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107cdf0e10cSrcweir return false; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir hasJeditInstallation()111cdf0e10cSrcweir public static boolean hasJeditInstallation() { 112cdf0e10cSrcweir boolean result = false; 113cdf0e10cSrcweir try 114cdf0e10cSrcweir { 115cdf0e10cSrcweir result = checkForSupportedVersion( getJeditLocation(), versions ); 116cdf0e10cSrcweir if ( !result ) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir System.out.println("No supported version for JEdit found."); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir catch ( IOException ioe ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir System.err.println("Exception caught trying to determine jedit installation: " + ioe ); 124cdf0e10cSrcweir ioe.printStackTrace(); 125cdf0e10cSrcweir result = false; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir return result; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir 131cdf0e10cSrcweir getNetbeansLocation()132cdf0e10cSrcweir public static Properties getNetbeansLocation() throws IOException { 133cdf0e10cSrcweir File theFile = null; 134cdf0e10cSrcweir Properties results = new Properties(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir StringBuffer str = new StringBuffer(); 137cdf0e10cSrcweir str.append(System.getProperty("user.home")); 138cdf0e10cSrcweir str.append(File.separator); 139cdf0e10cSrcweir StringBuffer thePath = new StringBuffer(str.toString()); 140cdf0e10cSrcweir 141cdf0e10cSrcweir String os = System.getProperty("os.name"); 142cdf0e10cSrcweir 143cdf0e10cSrcweir if (os.indexOf("Windows") != -1) { 144cdf0e10cSrcweir //theFile = findVersionFile(new File(str.toString())); 145cdf0e10cSrcweir thePath.append(".netbeans"); 146cdf0e10cSrcweir //theFile = new File(thePath.toString()); 147cdf0e10cSrcweir } else if (os.indexOf("SunOS") != -1) { 148cdf0e10cSrcweir thePath.append(".netbeans"); 149cdf0e10cSrcweir //theFile = new File(thePath.toString()); 150cdf0e10cSrcweir } else if (os.indexOf("Linux") != -1) { 151cdf0e10cSrcweir thePath.append(".netbeans"); 152cdf0e10cSrcweir //theFile = new File(thePath.toString()); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir if ( thePath.toString().indexOf( ".netbeans" ) == -1 ) 156cdf0e10cSrcweir return null; 157cdf0e10cSrcweir else if ( new File( thePath.append( File.separator+"3.4"+File.separator ).toString() ).isDirectory() ) { 158cdf0e10cSrcweir 159cdf0e10cSrcweir System.out.println( "Found NetBeans 3.4 user directory: " + thePath ); 160cdf0e10cSrcweir File netbeansLogFile = new File( thePath.toString() + File.separator + "system" + File.separator + "ide.log" ); 161cdf0e10cSrcweir if( netbeansLogFile.exists() ) { 162cdf0e10cSrcweir String installPath = getNetbeansInstallation( netbeansLogFile ); 163cdf0e10cSrcweir File f = new File(installPath); 164cdf0e10cSrcweir results.put("NetBeans 3.4", f.getPath()+File.separator); 165cdf0e10cSrcweir System.out.println( "NetBeans Installation directory: " + f.getPath()); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir else { 168cdf0e10cSrcweir System.out.println( "No NetBeans log file found" ); 169cdf0e10cSrcweir return null; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir else 173cdf0e10cSrcweir { 174cdf0e10cSrcweir System.out.println( "No NetBeans user directory found" ); 175cdf0e10cSrcweir return null; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir 179cdf0e10cSrcweir return results; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir 183cdf0e10cSrcweir getJeditLocation()184cdf0e10cSrcweir public static Properties getJeditLocation() throws IOException { 185cdf0e10cSrcweir 186cdf0e10cSrcweir /*if( !hasJeditInstallation() ) { 187cdf0e10cSrcweir System.out.println( "No Jedit found (line195 InstUtil"); 188cdf0e10cSrcweir return null; 189cdf0e10cSrcweir }*/ 190cdf0e10cSrcweir 191cdf0e10cSrcweir File theFile = null; 192cdf0e10cSrcweir Properties results = new Properties(); 193cdf0e10cSrcweir 194cdf0e10cSrcweir StringBuffer str = new StringBuffer(); 195cdf0e10cSrcweir str.append(System.getProperty("user.home")); 196cdf0e10cSrcweir str.append(File.separator); 197cdf0e10cSrcweir StringBuffer thePath = new StringBuffer(str.toString()); 198cdf0e10cSrcweir 199cdf0e10cSrcweir String os = System.getProperty("os.name"); 200cdf0e10cSrcweir thePath.append(".jedit"); 201cdf0e10cSrcweir //System.out.println( ".jedit path " + thePath ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir File jeditLogFile = new File( thePath.toString() + File.separator + "activity.log" ); 204cdf0e10cSrcweir if( jeditLogFile.exists() ) { 205cdf0e10cSrcweir String[] jeditDetails = getJeditInstallation( jeditLogFile ); 206cdf0e10cSrcweir System.out.println( "getJeditLocation ) " + jeditDetails[0] ); 207cdf0e10cSrcweir File f = new File(jeditDetails[0]); 208cdf0e10cSrcweir results.put("jEdit "+jeditDetails[1], jeditDetails[0]); 209cdf0e10cSrcweir System.out.println( "jeditDetails[0] is " + jeditDetails[0]); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir else { 212cdf0e10cSrcweir System.out.println( "Prompt user for Jedit installation path" ); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir 216cdf0e10cSrcweir return results; 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir 220cdf0e10cSrcweir 221cdf0e10cSrcweir 222cdf0e10cSrcweir getNetbeansInstallation( File logFile )223cdf0e10cSrcweir private static String getNetbeansInstallation( File logFile ) { 224cdf0e10cSrcweir String installPath = ""; 225cdf0e10cSrcweir try { 226cdf0e10cSrcweir BufferedReader reader = new BufferedReader(new FileReader(logFile)); 227cdf0e10cSrcweir 228cdf0e10cSrcweir for (String s = reader.readLine(); s != null; s = reader.readLine()) { 229cdf0e10cSrcweir s.trim(); 230cdf0e10cSrcweir if( s.indexOf( "IDE Install" ) != -1 ) { 231cdf0e10cSrcweir int pathStart = s.indexOf( "=" ) + 2; 232cdf0e10cSrcweir //System.out.println( "pathStart " + pathStart ); 233cdf0e10cSrcweir installPath = s.substring( pathStart, s.length() ); 234cdf0e10cSrcweir //System.out.println( "installPath 1" + installPath ); 235cdf0e10cSrcweir int pathEnd = installPath.indexOf( ";"); 236cdf0e10cSrcweir //System.out.println( "pathEnd " + pathEnd ); 237cdf0e10cSrcweir installPath = installPath.substring( 0, pathEnd ) +File.separator; 238cdf0e10cSrcweir //System.out.println( "pathStart " + pathStart ); 239cdf0e10cSrcweir //int pathEnd = s.indexOf( ";"); 240cdf0e10cSrcweir //System.out.println( "pathEnd " + pathEnd ); 241cdf0e10cSrcweir //System.out.println( "s is " + s + " and " + s.length() + " long" ); 242cdf0e10cSrcweir //installPath = s.substring( pathStart, pathEnd - 1 ); 243cdf0e10cSrcweir installPath.trim(); 244cdf0e10cSrcweir break; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir } 247cdf0e10cSrcweir } 248cdf0e10cSrcweir catch( IOException ioe ) { 249cdf0e10cSrcweir System.out.println( "Error reading Netbeans location information" ); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir //catch( FileNotFoundException fnfe ) { 252cdf0e10cSrcweir //System.out.println( "NetBeans ide.log FileNotFoundException" ); 253cdf0e10cSrcweir //} 254cdf0e10cSrcweir 255cdf0e10cSrcweir return installPath; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir getJeditInstallation( File logFile )259cdf0e10cSrcweir private static String[] getJeditInstallation( File logFile ) { 260cdf0e10cSrcweir String[] jeditDetails = new String[2]; 261cdf0e10cSrcweir try { 262cdf0e10cSrcweir BufferedReader reader = new BufferedReader(new FileReader(logFile)); 263cdf0e10cSrcweir String installPath = ""; 264cdf0e10cSrcweir String version = ""; 265cdf0e10cSrcweir 266cdf0e10cSrcweir for (String s = reader.readLine(); s != null; s = reader.readLine()) { 267cdf0e10cSrcweir s.trim(); 268cdf0e10cSrcweir if( s.indexOf( "jEdit home directory is" ) != -1 ) { 269cdf0e10cSrcweir int pathStart = new String( "[message] jEdit: jEdit home directory is " ).length(); 270cdf0e10cSrcweir //System.out.println( "pathStart " + pathStart ); 271cdf0e10cSrcweir installPath = s.substring( pathStart, s.length() ) +File.separator; 272cdf0e10cSrcweir System.out.println( "installPath 1" + installPath ); 273cdf0e10cSrcweir //int pathEnd = installPath.indexOf( ";"); 274cdf0e10cSrcweir //System.out.println( "pathEnd " + pathEnd ); 275cdf0e10cSrcweir //installPath = installPath.substring( 0, pathEnd ) +File.separator; 276cdf0e10cSrcweir //System.out.println( "pathStart " + pathStart ); 277cdf0e10cSrcweir //int pathEnd = s.indexOf( ";"); 278cdf0e10cSrcweir //System.out.println( "pathEnd " + pathEnd ); 279cdf0e10cSrcweir //System.out.println( "s is " + s + " and " + s.length() + " long" ); 280cdf0e10cSrcweir //installPath = s.substring( pathStart, pathEnd - 1 ); 281cdf0e10cSrcweir installPath.trim(); 282cdf0e10cSrcweir //System.out.println( "installPath 2 " + installPath ); 283cdf0e10cSrcweir //break; 284cdf0e10cSrcweir jeditDetails[0] = installPath; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir if( s.indexOf( "jEdit: jEdit version" ) != -1 ) { 287cdf0e10cSrcweir int versionStart = s.indexOf( "version" ) + 8; 288cdf0e10cSrcweir System.out.println( "versionStart is: " + versionStart ); 289cdf0e10cSrcweir version = s.substring( versionStart, s.length() ); 290cdf0e10cSrcweir version.trim(); 291cdf0e10cSrcweir System.out.println( "jEdit version is: " + version ); 292cdf0e10cSrcweir jeditDetails[1] = version; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir } 296cdf0e10cSrcweir catch( IOException ioe ) { 297cdf0e10cSrcweir System.out.println( "Error reading Jedit location information" ); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir //catch( FileNotFoundException fnfe ) { 300cdf0e10cSrcweir //System.out.println( "Jedit activity.log FileNotFoundException" ); 301cdf0e10cSrcweir //} 302cdf0e10cSrcweir 303cdf0e10cSrcweir return jeditDetails; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir 307cdf0e10cSrcweir findVersionFile(File start)308cdf0e10cSrcweir public static File findVersionFile(File start) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir File versionFile = null; 311cdf0e10cSrcweir 312cdf0e10cSrcweir File files[] = start.listFiles(new VersionFilter()); 313cdf0e10cSrcweir if (files.length == 0) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir File dirs[] = start.listFiles(new DirFilter()); 316cdf0e10cSrcweir for (int i=0; i< dirs.length; i++) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir versionFile = findVersionFile(dirs[i]); 319cdf0e10cSrcweir if (versionFile != null) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir break; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir else 326cdf0e10cSrcweir { 327cdf0e10cSrcweir versionFile = files[0]; 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir return versionFile; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir verifySversionExists(File sversionFile)333cdf0e10cSrcweir public static boolean verifySversionExists(File sversionFile) { 334cdf0e10cSrcweir if (!sversionFile.exists()) 335cdf0e10cSrcweir return false; 336cdf0e10cSrcweir return true; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir getOfficeVersions(File sversionFile)339cdf0e10cSrcweir public static Properties getOfficeVersions(File sversionFile) throws IOException { 340cdf0e10cSrcweir BufferedReader reader = new BufferedReader(new FileReader(sversionFile)); 341cdf0e10cSrcweir Vector values; 342cdf0e10cSrcweir String sectionName = null; 343cdf0e10cSrcweir Properties results = new Properties(); 344cdf0e10cSrcweir 345cdf0e10cSrcweir for (String s = reader.readLine(); s != null; s = reader.readLine()) { 346cdf0e10cSrcweir s.trim(); 347cdf0e10cSrcweir //System.out.println(s); 348cdf0e10cSrcweir if (s.length() == 0) 349cdf0e10cSrcweir continue; 350cdf0e10cSrcweir if (s.charAt(0) == '[') { 351cdf0e10cSrcweir sectionName = s.substring(1, s.length() - 1); 352cdf0e10cSrcweir //System.out.println(sectionName); 353cdf0e10cSrcweir continue; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir if ((sectionName != null) && sectionName.equalsIgnoreCase("Versions")) { 356cdf0e10cSrcweir int equals = s.indexOf( "=" ); 357cdf0e10cSrcweir String officeName = s.substring(0, equals ); 358cdf0e10cSrcweir 359cdf0e10cSrcweir String instPath = s.substring(equals + 8, s.length()); 360cdf0e10cSrcweir String [] parts = new String[2]; 361cdf0e10cSrcweir parts[0] = officeName; 362cdf0e10cSrcweir parts[1] = instPath + File.separator; 363cdf0e10cSrcweir //System.out.println( "InstUtil officeName " + officeName ); 364cdf0e10cSrcweir //System.out.println( "InstUtil instPath " + instPath ); 365cdf0e10cSrcweir 366cdf0e10cSrcweir //String [] parts = s.split("="); 367cdf0e10cSrcweir if (parts.length == 2) { 368cdf0e10cSrcweir //ver.version = parts[0].trim(); 369cdf0e10cSrcweir //File f = new File(parts[1].trim()); 370cdf0e10cSrcweir //results.put(parts[0].trim(), f.getPath()); 371cdf0e10cSrcweir try { 372cdf0e10cSrcweir URL url = new URL("file://" + parts[1].trim()); 373cdf0e10cSrcweir String opSys =System.getProperty("os.name"); 374cdf0e10cSrcweir if (opSys.indexOf("Windows")!=-1){ 375cdf0e10cSrcweir String windowsPath = URLDecoder.decode( url.getPath() ); 376cdf0e10cSrcweir boolean firstSlash = true; 377cdf0e10cSrcweir while( windowsPath.indexOf("/") != -1 ) { 378cdf0e10cSrcweir int forwardSlashPos = windowsPath.indexOf("/"); 379cdf0e10cSrcweir String firstPart = windowsPath.substring( 0, forwardSlashPos ); 380cdf0e10cSrcweir String lastPart = windowsPath.substring( forwardSlashPos + 1, windowsPath.length() ); 381cdf0e10cSrcweir if( firstSlash ) { 382cdf0e10cSrcweir windowsPath = lastPart; 383cdf0e10cSrcweir firstSlash = false; 384cdf0e10cSrcweir } 385cdf0e10cSrcweir else { 386cdf0e10cSrcweir windowsPath = firstPart + "\\" + lastPart; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir } 389cdf0e10cSrcweir int lastSlash = windowsPath.lastIndexOf("\\"); 390cdf0e10cSrcweir windowsPath = windowsPath.substring( 0, lastSlash ); 391cdf0e10cSrcweir results.put( parts[0].trim(), windowsPath ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else { 394cdf0e10cSrcweir //System.err.println( " InstUtil URLDecoder " + URLDecoder.decode(url.getPath()) ); 395cdf0e10cSrcweir results.put(parts[0].trim(), URLDecoder.decode(url.getPath())); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir //File f = new File(url); 398cdf0e10cSrcweir 399cdf0e10cSrcweir //.sversion: OpenOffice.org 643=file:///scriptdev/neil/ScriptFrameOpenoffice1.0.1 400cdf0e10cSrcweir // parts = Installation name. f.getPath = Installation path 401cdf0e10cSrcweir //results.put(parts[0].trim(), f.getPath()); 402cdf0e10cSrcweir 403cdf0e10cSrcweir //results.put(parts[0].trim(), URLDecoder.decode(url.getPath())); 404cdf0e10cSrcweir //results.put( parts[0].trim(), windowsPath ); 405cdf0e10cSrcweir 406cdf0e10cSrcweir } 407cdf0e10cSrcweir catch (MalformedURLException eSyntax) { 408cdf0e10cSrcweir //throw new IOException("Error while reading version information"); 409cdf0e10cSrcweir results.put(parts[0].trim(), parts[1].trim()); 410cdf0e10cSrcweir //System.out.println(parts[0].trim() + " : " + parts[1].trim()); 411cdf0e10cSrcweir System.err.println("GotHereException"); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir else { 415cdf0e10cSrcweir System.out.println("not splitting on equals"); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir } 418cdf0e10cSrcweir } 419cdf0e10cSrcweir 420cdf0e10cSrcweir return results; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir getJavaVersion()423cdf0e10cSrcweir public static String getJavaVersion() { 424cdf0e10cSrcweir return System.getProperty("java.version"); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir isCorrectJavaVersion()427cdf0e10cSrcweir public static boolean isCorrectJavaVersion() { 428cdf0e10cSrcweir if (System.getProperty("java.version").startsWith("1.4")) 429cdf0e10cSrcweir return true; 430cdf0e10cSrcweir return false; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir main(String args[])433cdf0e10cSrcweir public static void main(String args[]) { 434cdf0e10cSrcweir InstUtil inst = new InstUtil(); 435cdf0e10cSrcweir File f = null; 436cdf0e10cSrcweir try 437cdf0e10cSrcweir { 438cdf0e10cSrcweir f = inst.buildSversionLocation(); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir catch (IOException e) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir e.printStackTrace(); 443cdf0e10cSrcweir System.out.println(e.getMessage()); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir if (!inst.verifySversionExists(f)) { 446cdf0e10cSrcweir System.err.println("Problem with sversion.ini"); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir try { 449cdf0e10cSrcweir Properties vers = inst.getOfficeVersions(f); 450cdf0e10cSrcweir } catch (IOException e) { 451cdf0e10cSrcweir e.printStackTrace(); 452cdf0e10cSrcweir System.err.println(e); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir System.out.println(inst.getJavaVersion()); 455cdf0e10cSrcweir if (!inst.isCorrectJavaVersion()) { 456cdf0e10cSrcweir System.err.println("Not correct Java Version"); 457cdf0e10cSrcweir } 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir public static final String [] versions = {"NetBeans 3.4", "jEdit 4.0.3", "jEdit 4.1pre5" }; 461cdf0e10cSrcweir private static File tmpDir = null; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir 465cdf0e10cSrcweir 466cdf0e10cSrcweir class DirFilter implements java.io.FileFilter 467cdf0e10cSrcweir { accept(File aFile)468cdf0e10cSrcweir public boolean accept(File aFile) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir return aFile.isDirectory(); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir } 473cdf0e10cSrcweir class VersionFilter implements java.io.FileFilter 474cdf0e10cSrcweir { accept(File aFile)475cdf0e10cSrcweir public boolean accept(File aFile) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir if (aFile.getName().compareToIgnoreCase("sversion.ini") == 0) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir return true; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir return false; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir } 485