blob: 8c9deb10338a17603f00ff4795f8913b74beba36 [file] [log] [blame]
Shawn O. Pearce44671f52009-11-07 12:55:26 -08001// Copyright (C) 2009 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Shawn O. Pearce44671f52009-11-07 12:55:26 -080015public final class Main {
16 // We don't do any real work here because we need to import
17 // the archive lookup code and we cannot import a class in
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080018 // the default package. So this is just a tiny springboard
Shawn O. Pearce44671f52009-11-07 12:55:26 -080019 // to jump into the real main code.
20 //
21
David Pursehoused70fc022015-03-16 17:35:21 +090022 public static void main(final String[] argv) throws Exception {
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080023 if (onSupportedJavaVersion()) {
24 com.google.gerrit.launcher.GerritLauncher.main(argv);
25
26 } else {
27 System.exit(1);
28 }
29 }
30
31 private static boolean onSupportedJavaVersion() {
32 final String version = System.getProperty("java.specification.version");
David Ostrovsky3931c162014-06-15 00:33:40 +020033 if (1.8 <= parse(version)) {
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080034 return true;
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080035 }
David Ostrovsky3931c162014-06-15 00:33:40 +020036 System.err.println("fatal: Gerrit Code Review requires Java 8 or later");
David Pursehouse32324722016-06-01 21:20:02 +090037 System.err.println(" (trying to run on Java " + version + ")");
38 return false;
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080039 }
40
41 private static double parse(String version) {
42 if (version == null || version.length() == 0) {
43 return 0.0;
44 }
45
46 try {
47 final int fd = version.indexOf('.');
48 final int sd = version.indexOf('.', fd + 1);
49 if (0 < sd) {
50 version = version.substring(0, sd);
51 }
52 return Double.parseDouble(version);
53 } catch (NumberFormatException e) {
54 return 0.0;
55 }
Shawn O. Pearce44671f52009-11-07 12:55:26 -080056 }
57
Dave Borowitz292fa152016-11-13 09:56:32 -080058 private Main() {}
Shawn O. Pearce44671f52009-11-07 12:55:26 -080059}