001/*
002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved.
003 * 
004 * http://www.izforge.com/izpack/
005 * http://developer.berlios.de/projects/izpack/
006 * 
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 * 
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *     
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package com.izforge.izpack.uninstaller;
021
022import java.lang.reflect.Method;
023
024import javax.swing.UIManager;
025
026/**
027 * The uninstaller class.
028 * 
029 * @author Julien Ponge
030 */
031public class Uninstaller
032{
033
034    /**
035     * The main method (program entry point).
036     * 
037     * @param args The arguments passed on the command line.
038     */
039    public static void main(String[] args)
040    {
041        try
042        {
043            Class clazz = Uninstaller.class;
044            Method target = clazz.getMethod("uninstall", new Class[] { String[].class});
045            new SelfModifier(target).invoke(args);
046        }
047        catch (Exception ioeOrTypo)
048        {
049            System.err.println(ioeOrTypo.getMessage());
050            ioeOrTypo.printStackTrace();
051            System.err.println("Unable to exec java as a subprocess.");
052            System.err.println("The uninstall may not fully complete.");
053            uninstall(args);
054        }
055    }
056
057    public static void uninstall(String[] args)
058    {
059        try
060        {
061            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
062            new UninstallerFrame();
063        }
064        catch (Exception err)
065        {
066            System.err.println("- Error -");
067            err.printStackTrace();
068            System.exit(0);
069        }
070    }
071}