Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/extcheck/Main.java
38920 views
/*1* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.extcheck;2627import java.io.*;2829/**30* Main program of extcheck31*/3233public final class Main {34public static final String INSUFFICIENT = "Insufficient number of arguments";35public static final String MISSING = "Missing <jar file> argument";36public static final String DOES_NOT_EXIST = "Jarfile does not exist: ";37public static final String EXTRA = "Extra command line argument: ";3839/**40* Terminates with one of the following codes41* 1 A newer (or same version) jar file is already installed42* 0 No newer jar file was found43* -1 An internal error occurred44*/45public static void main(String args[]) {46try {47realMain(args);48} catch (Exception ex) {49System.err.println(ex.getMessage());50System.exit(-1);51}52}5354public static void realMain(String[] args) throws Exception {55if (args.length < 1) {56usage(INSUFFICIENT);57}58int argIndex = 0;59boolean verboseFlag = false;60if (args[argIndex].equals("-verbose")) {61verboseFlag = true;62argIndex++;63if (argIndex >= args.length) {64usage(MISSING);65}66}67String jarName = args[argIndex];68argIndex++;69File jarFile = new File(jarName);70if (!jarFile.exists()){71usage(DOES_NOT_EXIST + jarName);72}73if (argIndex < args.length) {74usage(EXTRA + args[argIndex]);75}76ExtCheck jt = ExtCheck.create(jarFile,verboseFlag);77boolean result = jt.checkInstalledAgainstTarget();78if (result) {79System.exit(0);80} else {81System.exit(1);82}83}8485private static void usage(String msg) throws Exception {86throw new Exception(msg + "\nUsage: extcheck [-verbose] <jar file>");87}88}89909192