Shawn O. Pearce | 44671f5 | 2009-11-07 12:55:26 -0800 | [diff] [blame] | 1 | // 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 | |
| 16 | public 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. Pearce | 6ee0554 | 2009-12-18 15:33:35 -0800 | [diff] [blame] | 19 | // the default package. So this is just a tiny springboard |
Shawn O. Pearce | 44671f5 | 2009-11-07 12:55:26 -0800 | [diff] [blame] | 20 | // to jump into the real main code. |
| 21 | // |
| 22 | |
| 23 | public static void main(final String argv[]) throws Exception { |
Shawn O. Pearce | 6ee0554 | 2009-12-18 15:33:35 -0800 | [diff] [blame] | 24 | 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"); |
| 34 | if (1.6 <= parse(version)) { |
| 35 | return true; |
| 36 | |
| 37 | } else { |
| 38 | System.err.println("fatal: Gerrit Code Review requires Java 6 or later"); |
| 39 | System.err.println(" (trying to run on Java " + version + ")"); |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | private static double parse(String version) { |
| 45 | if (version == null || version.length() == 0) { |
| 46 | return 0.0; |
| 47 | } |
| 48 | |
| 49 | try { |
| 50 | final int fd = version.indexOf('.'); |
| 51 | final int sd = version.indexOf('.', fd + 1); |
| 52 | if (0 < sd) { |
| 53 | version = version.substring(0, sd); |
| 54 | } |
| 55 | return Double.parseDouble(version); |
| 56 | } catch (NumberFormatException e) { |
| 57 | return 0.0; |
| 58 | } |
Shawn O. Pearce | 44671f5 | 2009-11-07 12:55:26 -0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | private Main() { |
| 62 | } |
| 63 | } |