PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/installer/Install.java

#
Java | 93 lines | 66 code | 8 blank | 19 comment | 11 complexity | baf313c7eba783fbedb25fc0bb35caef MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * Install.java - Main class of the installer
  3. * Copyright (C) 1999, 2000, 2001 Slava Pestov
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package installer;
  20. import javax.swing.plaf.metal.MetalLookAndFeel;
  21. import java.io.InputStream;
  22. import java.io.IOException;
  23. import java.util.Properties;
  24. public class Install
  25. {
  26. public static void main(String[] args)
  27. {
  28. String javaVersion = System.getProperty("java.version");
  29. if(javaVersion.compareTo("1.3") < 0)
  30. {
  31. System.err.println("You are running Java version "
  32. + javaVersion + ".");
  33. System.err.println("This installer requires Java 1.3 or later.");
  34. System.exit(1);
  35. }
  36. if(args.length == 0)
  37. {
  38. MetalLookAndFeel.setCurrentTheme(new JEditMetalTheme());
  39. new SwingInstall();
  40. }
  41. else if(args.length == 1 && args[0].equals("text"))
  42. new ConsoleInstall();
  43. else if(args.length == 3 && args[0].equals("auto"))
  44. new NonInteractiveInstall(args[1],args[2]);
  45. else
  46. {
  47. System.err.println("Usage:");
  48. System.err.println("jre -cp <installer JAR> installer.Install [text] (Java 1.1)");
  49. System.err.println("java -jar <installer JAR> [text] (Java 2)");
  50. System.err.println("text parameter starts installer in text-only mode");
  51. }
  52. }
  53. public Install()
  54. {
  55. props = new Properties();
  56. try
  57. {
  58. InputStream in = getClass().getResourceAsStream("install.props");
  59. props.load(in);
  60. in.close();
  61. }
  62. catch(IOException io)
  63. {
  64. System.err.println("Error loading 'install.props':");
  65. io.printStackTrace();
  66. }
  67. }
  68. public String getProperty(String name)
  69. {
  70. return props.getProperty(name);
  71. }
  72. public int getIntProperty(String name)
  73. {
  74. try
  75. {
  76. return Integer.parseInt(props.getProperty(name));
  77. }
  78. catch(Exception e)
  79. {
  80. return -1;
  81. }
  82. }
  83. // private members
  84. private Properties props;
  85. }