blob: 58de6a453f79222dd9fa7f1181bf373d5753e2b4 [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
15
16public final class Main {
17 // We don't do any real work here because we need to import
18 // the archive lookup code and we cannot import a class in
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080019 // the default package. So this is just a tiny springboard
Shawn O. Pearce44671f52009-11-07 12:55:26 -080020 // to jump into the real main code.
21 //
22
David Pursehoused70fc022015-03-16 17:35:21 +090023 public static void main(final String[] argv) throws Exception {
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080024 if (onSupportedJavaVersion()) {
25 com.google.gerrit.launcher.GerritLauncher.main(argv);
26
27 } else {
28 System.exit(1);
29 }
30 }
31
32 private static boolean onSupportedJavaVersion() {
33 final String version = System.getProperty("java.specification.version");
David Ostrovsky3931c162014-06-15 00:33:40 +020034 if (1.8 <= parse(version)) {
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080035 return true;
36
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080037 }
David Ostrovsky3931c162014-06-15 00:33:40 +020038 System.err.println("fatal: Gerrit Code Review requires Java 8 or later");
David Pursehouse32324722016-06-01 21:20:02 +090039 System.err.println(" (trying to run on Java " + version + ")");
40 return false;
Shawn O. Pearce6ee05542009-12-18 15:33:35 -080041 }
42
43 private static double parse(String version) {
44 if (version == null || version.length() == 0) {
45 return 0.0;
46 }
47
48 try {
49 final int fd = version.indexOf('.');
50 final int sd = version.indexOf('.', fd + 1);
51 if (0 < sd) {
52 version = version.substring(0, sd);
53 }
54 return Double.parseDouble(version);
55 } catch (NumberFormatException e) {
56 return 0.0;
57 }
Shawn O. Pearce44671f52009-11-07 12:55:26 -080058 }
59
60 private Main() {
61 }
62}