PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 101 lines | 74 code | 8 blank | 19 comment | 14 complexity | 7deb0639cc15f46ba91bc18eccf54d90 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 == 2 || args.length == 3)
  44. && args[0].equals("auto"))
  45. {
  46. new NonInteractiveInstall(args[1],
  47. (args.length == 3 ? args[2]
  48. : ""));
  49. }
  50. else
  51. {
  52. System.err.println("Usage:");
  53. System.err.println("java -jar <installer JAR>");
  54. System.err.println("java -jar <installer JAR> text");
  55. System.err.println("java -jar <installer JAR> auto"
  56. + " <install dir> [<shortcut dir>]");
  57. System.err.println("text parameter starts installer in text-only mode.");
  58. System.err.println("auto parameter starts installer in non-interactive mode.");
  59. }
  60. }
  61. public Install()
  62. {
  63. props = new Properties();
  64. try
  65. {
  66. InputStream in = getClass().getResourceAsStream("install.props");
  67. props.load(in);
  68. in.close();
  69. }
  70. catch(IOException io)
  71. {
  72. System.err.println("Error loading 'install.props':");
  73. io.printStackTrace();
  74. }
  75. }
  76. public String getProperty(String name)
  77. {
  78. return props.getProperty(name);
  79. }
  80. public int getIntProperty(String name)
  81. {
  82. try
  83. {
  84. return Integer.parseInt(props.getProperty(name));
  85. }
  86. catch(Exception e)
  87. {
  88. return -1;
  89. }
  90. }
  91. // private members
  92. private Properties props;
  93. }