PageRenderTime 52ms CodeModel.GetById 30ms app.highlight 7ms RepoModel.GetById 13ms 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
  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
 20package installer;
 21
 22import javax.swing.plaf.metal.MetalLookAndFeel;
 23import java.io.InputStream;
 24import java.io.IOException;
 25import java.util.Properties;
 26
 27public class Install
 28{
 29	public static void main(String[] args)
 30	{
 31		String javaVersion = System.getProperty("java.version");
 32		if(javaVersion.compareTo("1.3") < 0)
 33		{
 34			System.err.println("You are running Java version "
 35				+ javaVersion + ".");
 36			System.err.println("This installer requires Java 1.3 or later.");
 37			System.exit(1);
 38		}
 39
 40		if(args.length == 0)
 41		{
 42			MetalLookAndFeel.setCurrentTheme(new JEditMetalTheme());
 43			new SwingInstall();
 44		}
 45		else if(args.length == 1 && args[0].equals("text"))
 46			new ConsoleInstall();
 47		else if((args.length == 2 || args.length == 3)
 48			&& args[0].equals("auto"))
 49		{
 50			new NonInteractiveInstall(args[1],
 51				(args.length == 3 ? args[2]
 52				: ""));
 53		}
 54		else
 55		{
 56			System.err.println("Usage:");
 57			System.err.println("java -jar <installer JAR>");
 58			System.err.println("java -jar <installer JAR> text");
 59			System.err.println("java -jar <installer JAR> auto"
 60				+ " <install dir> [<shortcut dir>]");
 61			System.err.println("text parameter starts installer in text-only mode.");
 62			System.err.println("auto parameter starts installer in non-interactive mode.");
 63		}
 64	}
 65
 66	public Install()
 67	{
 68		props = new Properties();
 69		try
 70		{
 71			InputStream in = getClass().getResourceAsStream("install.props");
 72			props.load(in);
 73			in.close();
 74		}
 75		catch(IOException io)
 76		{
 77			System.err.println("Error loading 'install.props':");
 78			io.printStackTrace();
 79		}
 80	}
 81
 82	public String getProperty(String name)
 83	{
 84		return props.getProperty(name);
 85	}
 86
 87	public int getIntProperty(String name)
 88	{
 89		try
 90		{
 91			return Integer.parseInt(props.getProperty(name));
 92		}
 93		catch(Exception e)
 94		{
 95			return -1;
 96		}
 97	}
 98
 99	// private members
100	private Properties props;
101}