PageRenderTime 159ms CodeModel.GetById 153ms app.highlight 3ms 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
 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 == 3 && args[0].equals("auto"))
48			new NonInteractiveInstall(args[1],args[2]);
49		else
50		{
51			System.err.println("Usage:");
52			System.err.println("jre -cp <installer JAR> installer.Install [text] (Java 1.1)");
53			System.err.println("java -jar <installer JAR> [text] (Java 2)");
54			System.err.println("text parameter starts installer in text-only mode");
55		}
56	}
57
58	public Install()
59	{
60		props = new Properties();
61		try
62		{
63			InputStream in = getClass().getResourceAsStream("install.props");
64			props.load(in);
65			in.close();
66		}
67		catch(IOException io)
68		{
69			System.err.println("Error loading 'install.props':");
70			io.printStackTrace();
71		}
72	}
73
74	public String getProperty(String name)
75	{
76		return props.getProperty(name);
77	}
78
79	public int getIntProperty(String name)
80	{
81		try
82		{
83			return Integer.parseInt(props.getProperty(name));
84		}
85		catch(Exception e)
86		{
87			return -1;
88		}
89	}
90
91	// private members
92	private Properties props;
93}