<p>
Prints the manifest information to standard output.</p>
<ul><li>Implementation-Title: ${pom.name}</li>
<li>Implementation-Version: ${pom.version}</li></ul>
558201
public void printVersionInfo() {
        final String version = String.format("%s version %s",
                settings.getString(Settings.KEYS.APPLICATION_NAME, "dependency-check"),
                settings.getString(Settings.KEYS.APPLICATION_VERSION, "Unknown"));
        System.out.println(version);
    }
1027544
private void logJavaInfo() {
        log("Operating system: " + VersionFinder.getProperty("os.name") + " "
                + VersionFinder.getProperty("os.version") + " " + VersionFinder.getProperty("os.arch"));
        log("Java version: " + VersionFinder.getProperty("java.version") + " / "
                + VersionFinder.getProperty("java.runtime.version") + " ("
                + VersionFinder.getProperty("java.vendor") + ")");
        log("Java home: " + VersionFinder.getProperty("java.home"));
        final String jreRtJarPath = SystemJarFinder.getJreRtJarPath();
        if (jreRtJarPath != null) {
            log("JRE rt.jar:").log(jreRtJarPath);
        }
    }
50637
public static String getImplementationVersion(Class<?> clazz) {
        /*
         * We don't use Package.getImplementationVersion() due to
         * a duplicate package would override the origin package info.
         * https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest
         */
        String className = clazz.getSimpleName() + ".class";
        String classPath = clazz.getResource(className).toString();
        if (!classPath.startsWith("jar:file:")) {
          // Class not from JAR
          return null;
        }
        // Get manifest
        int offset = classPath.lastIndexOf("!");
        assert offset > 0;
        String manifestPath = classPath.substring(0, offset + 1) +
                              "/META-INF/MANIFEST.MF";
        Manifest manifest = null;
        try {
            manifest = new Manifest(new URL(manifestPath).openStream());
        } catch (IOException ignored) {
            return null;
        }
        return manifest.getMainAttributes()
                       .getValue(Attributes.Name.IMPLEMENTATION_VERSION);
    }
837764
@SuppressWarnings("unused")
    private void printServerInfo() {
        Context ctx;
        try{
            ctx = new InitialContext();
            MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");
            ObjectName service = new ObjectName("com.bea:Name=RuntimeService," +
                  "Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
            ObjectName domainMBean = (ObjectName) server.getAttribute(service,
                "DomainConfiguration");
            ObjectName[] servers = (ObjectName[]) server.getAttribute(domainMBean,
                    "Servers");
            for (ObjectName one : servers) {
                String name = (String)server.getAttribute(one, "Name");
                String address = (String)server.getAttribute(one, "ListenAddress");
                Integer port = (Integer)server.getAttribute(one, "ListenPort");
                System.out.println("SERVER: " + name + " on " + address + ":" + port);
                ObjectName machine = (ObjectName)server.getAttribute(one, "Machine");
                ObjectName nodeManager = (ObjectName)server.getAttribute(machine, "NodeManager");
                // above line need WLS admin!!!
                address = (String)server.getAttribute(machine, "ListenAddress");
                System.out.println(" - hostname: " + address);
            }
            if (ctx!=null) return;
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
729517
@Override
  public String toMavenString()
  {
    String mavenString = "";
    switch (operator) {
      case "<=":
        mavenString = "(,%s]";
        break;
      case "<":
        mavenString = "(,%s)";
        break;
      case "==":
        mavenString = "[%s]";
        break;
      case ">=":
        mavenString = "[%s,)";
        break;
      case ">":
        mavenString = "(%s,)";
        break;
      default:
        toString();
    }
    return String.format(mavenString, version);
  }
986910
private static void outputHelp() {
        System.out.println("Usage: TzdbZoneRulesCompiler <options> <tzdb source filenames>");
        System.out.println("where options include:");
        System.out.println("   -srcdir <directory>   Where to find source directories (required)");
        System.out.println("   -dstdir <directory>   Where to output generated files (default srcdir)");
        System.out.println("   -version <version>    Specify the version, such as 2009a (optional)");
        System.out.println("   -unpacked             Generate dat files without jar files");
        System.out.println("   -help                 Print this usage message");
        System.out.println("   -verbose              Output verbose information during compilation");
        System.out.println(" There must be one directory for each version in srcdir");
        System.out.println(" Each directory must have the name of the version, such as 2009a");
        System.out.println(" Each directory must contain the unpacked tzdb files, such as asia or europe");
        System.out.println(" Directories must match the regex [12][0-9][0-9][0-9][A-Za-z0-9._-]+");
        System.out.println(" There will be one jar file for each version and one combined jar in dstdir");
        System.out.println(" If the version is specified, only that version is processed");
    }
966221
def view(self):
        
        print("")   # new line at start
        description, count = "", 0
        if self.repo == "sbo":
            description = SBoGrep(self.name).description()
        else:
            PACKAGES_TXT = Utils().read_file(self.lib)
            for line in PACKAGES_TXT.splitlines():
                if line.startswith(self.name + ":"):
                    description += line[len(self.name) + 2:] + "\n"
                    count += 1
                    if count == 11:
                        break
        if description:
            print("{0}{1}{2}".format(self.COLOR, description,
                                     self.meta.color["ENDC"]))
        else:
            self.msg.pkg_not_found("", self.name, "No matching", "\n")
            raise SystemExit(1)
        if description and self.repo == "sbo":
            print("")
626077
public String getImplementationTitle()
   {
      StringBuilder sb = new StringBuilder();
      sb.append("JBossWS ");
      sb.append(getClass().getPackage().getImplementationVersion());
      sb.append(" (Apache CXF ");
      sb.append(Bus.class.getPackage().getImplementationVersion());
      sb.append(")");
      return sb.toString();
   }
503480
public void verifyPom() {
        String pomFileName = pomFile.getAbsolutePath();
        log.info("Verifying file " + pomFileName);

        XmlOrderedResult xmlOrderedResult = isPomElementsSorted();
        if (!xmlOrderedResult.isOrdered()) {
            switch (verifyFailType) {
                case WARN:
                    log.warn(xmlOrderedResult.getErrorMessage());
                    saveViolationFile(xmlOrderedResult);
                    log.warn(String.format(TEXT_FILE_NOT_SORTED, pomFileName));
                    break;
                case SORT:
                    log.info(xmlOrderedResult.getErrorMessage());
                    saveViolationFile(xmlOrderedResult);
                    log.info(String.format(TEXT_FILE_NOT_SORTED, pomFileName));
                    sortPom();
                    break;
                case STOP:
                    log.error(xmlOrderedResult.getErrorMessage());
                    saveViolationFile(xmlOrderedResult);
                    log.error(String.format(TEXT_FILE_NOT_SORTED, pomFileName));
                    throw new FailureException(String.format(TEXT_FILE_NOT_SORTED, pomFileName));
            }
        }
    }
606952
public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
        try {
            Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
            while (resources.hasMoreElements()) {

                Manifest manifest = new Manifest(resources.nextElement().openStream());
                Attributes attribs = manifest.getMainAttributes();
                String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                if (ver == null) {
                	return _default;
                }

                String rev = attribs.getValue("Implementation-Revision");
                if (rev != null) {
                    ver += "-r" + rev;
                }
                return ver;

            }
        } catch (IOException _ex) {
        }

        return _default;
    }
725657
public static void main( String... args )
    {
        System.out.println( "Display parameters as parsed by Maven (in canonical form) and comparison result:" );
        if ( args.length == 0 )
        {
            return;
        }

        ComparableVersion prev = null;
        int i = 1;
        for ( String version : args )
        {
            ComparableVersion c = new ComparableVersion( version );

            if ( prev != null )
            {
                int compare = prev.compareTo( c );
                System.out.println( "   " + prev.toString() + ' '
                    + ( ( compare == 0 ) ? "==" : ( ( compare < 0 ) ? "<" : ">" ) ) + ' ' + version );
            }

            System.out.println( String.valueOf( i++ ) + ". " + version + " == " + c.getCanonical() );

            prev = c;
        }
    }
131355
private void initVersion() {

        // initialize version information with static defaults
        m_versionNumber = DEFAULT_VERSION_NUMBER;
        m_versionId = DEFAULT_VERSION_ID;
        m_version = "OpenCms/" + m_versionNumber;
        m_buildInfo = Collections.emptyMap();
        // read the version-informations from properties
        Properties props = new Properties();
        try {
            props.load(this.getClass().getClassLoader().getResourceAsStream("org/opencms/main/version.properties"));
        } catch (Throwable t) {
            // no properties found - we just use the defaults
            return;
        }
        // initialize OpenCms version information from the property values
        m_versionNumber = props.getProperty("version.number", DEFAULT_VERSION_NUMBER);
        m_versionId = props.getProperty("version.id", DEFAULT_VERSION_ID);
        m_version = "OpenCms/" + m_versionNumber;
        m_buildInfo = new TreeMap<String, BuildInfoItem>();

        // iterate the properties and generate the build information from the entries
        for (String key : props.stringPropertyNames()) {
            if (!"version.number".equals(key) && !"version.id".equals(key) && !key.startsWith("nicename")) {
                String value = props.getProperty(key);
                String nicename = props.getProperty("nicename." + key, key);
                m_buildInfo.put(key, new BuildInfoItem(value, nicename, key));
            }
        }
        // make the map unmodifiable
        m_buildInfo = Collections.unmodifiableMap(m_buildInfo);
    }
44456
@FFDCIgnore(IllegalArgumentException.class)
    private void definePackage(final ByteResourceInformation classBytesResourceInformation, String packageName) {
        /*
         * We don't extend URL classloader so we automatically pass the manifest from the JAR to our supertype, still try to get hold of it though so that we can see if
         * we can load the information ourselves from it
         */
        Manifest manifest = classBytesResourceInformation.getManifest();
        try {
            if (manifest == null) {
                definePackage(packageName, null, null, null, null, null, null, null);
            } else {
                String classResourceName = classBytesResourceInformation.getResourcePath();

                /*
                 * Strip the class name off the end of the package, should always have at least one '/' as we have at least one . in the name, also end with a trailing
                 * '/' to match the name style for package definitions in manifest files
                 */
                String packageResourceName = classResourceName.substring(0, classResourceName.lastIndexOf('/') + 1);

                // Default all of the package info to null
                String specTitle = null;
                String specVersion = null;
                String specVendor = null;
                String implTitle = null;
                String implVersion = null;
                String implVendor = null;
                URL sealBaseUrl = null;

                // See if there is a package defined in the manifest 
                Attributes packageAttributes = manifest.getAttributes(packageResourceName);
                if (packageAttributes != null && !packageAttributes.isEmpty()) {
                    specTitle = packageAttributes.getValue(Attributes.Name.SPECIFICATION_TITLE);
                    specVersion = packageAttributes.getValue(Attributes.Name.SPECIFICATION_VERSION);
                    specVendor = packageAttributes.getValue(Attributes.Name.SPECIFICATION_VENDOR);

                    implTitle = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
                    implVersion = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                    implVendor = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);

                    String sealedValue = packageAttributes.getValue(Attributes.Name.SEALED);
                    if (sealedValue != null && Boolean.parseBoolean(sealedValue)) {
                        sealBaseUrl = classBytesResourceInformation.getResourceUrl();
                    }
                }

                definePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBaseUrl);
            }
        } catch (IllegalArgumentException ignored) {
            // This happens if the package is already defined but it is hard to guard against this in a thread safe way. See:
            // http://bugs.sun.com/view_bug.do?bug_id=4841786
        }
    }
397519
public static synchronized String getVersion() {
        // Try to get version number from pom.xml (available when running in Eclipse)
        final Class<?> cls = ClassGraph.class;
        try {
            final String className = cls.getName();
            final URL classpathResource = cls.getResource("/" + JarUtils.classNameToClassfilePath(className));
            if (classpathResource != null) {
                final Path absolutePackagePath = Paths.get(classpathResource.toURI()).getParent();
                final int packagePathSegments = className.length() - className.replace(".", "").length();
                // Remove package segments from path
                Path path = absolutePackagePath;
                for (int i = 0; i < packagePathSegments && path != null; i++) {
                    path = path.getParent();
                }
                // Remove up to two more levels for "bin" or "target/classes"
                for (int i = 0; i < 3 && path != null; i++, path = path.getParent()) {
                    final Path pom = path.resolve("pom.xml");
                    try (InputStream is = Files.newInputStream(pom)) {
                        final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
                        doc.getDocumentElement().normalize();
                        String version = (String) XPathFactory.newInstance().newXPath().compile("/project/version")
                                .evaluate(doc, XPathConstants.STRING);
                        if (version != null) {
                            version = version.trim();
                            if (!version.isEmpty()) {
                                return version;
                            }
                        }
                    } catch (final IOException e) {
                        // Not found
                    }
                }
            }
        } catch (final Exception e) {
            // Ignore
        }

        // Try to get version number from maven properties in jar's META-INF directory
        try (InputStream is = cls.getResourceAsStream(
                "/META-INF/maven/" + MAVEN_PACKAGE + "/" + MAVEN_ARTIFACT + "/pom.properties")) {
            if (is != null) {
                final Properties p = new Properties();
                p.load(is);
                final String version = p.getProperty("version", "").trim();
                if (!version.isEmpty()) {
                    return version;
                }
            }
        } catch (final IOException e) {
            // Ignore
        }

        // Fallback to using Java API (version number is obtained from MANIFEST.MF)
        final Package pkg = cls.getPackage();
        if (pkg != null) {
            String version = pkg.getImplementationVersion();
            if (version == null) {
                version = "";
            }
            version = version.trim();
            if (version.isEmpty()) {
                version = pkg.getSpecificationVersion();
                if (version == null) {
                    version = "";
                }
                version = version.trim();
            }
            if (!version.isEmpty()) {
                return version;
            }
        }
        return "unknown";
    }
785836
public static void showLogo() {
        System.out.println("__________                 ___________");
        System.out.println("\\______   \\_____  ___  ___ \\_   _____/__  ________    _____");
        System.out.println(" |     ___/\\__  \\ \\  \\/  /  |    __)_\\  \\/  /\\__  \\  /     \\");
        System.out.println(" |    |     / __ \\_>    <   |        \\>    <  / __ \\|  Y Y  \\");
        System.out.println(" |____|    (____  /__/\\_ \\ /_______  /__/\\_ \\(____  /__|_|  /");
        System.out.println("                \\/      \\/         \\/      \\/     \\/      \\/");

        System.out.println();
        final String logo = "Pax Exam " + Info.getPaxExamVersion()
            + " from OPS4J - http://www.ops4j.org";
        System.out.println(logo);
        System.out
            .println("---------------------------------------------------------------------------------------------------------"
                .substring(0, logo.length()));
        System.out.println();
    }
790523
private static void logVersionInformation() {
		String version = JobManager.class.getPackage().getImplementationVersion();
		// if version == null, then the JobManager runs from inside the IDE (or somehow not from the maven build jar)
		String revision = "<unknown>";
		try {
			Properties properties = new Properties();
			InputStream propFile = JobManager.class.getClassLoader().getResourceAsStream(".version.properties");
			if (propFile != null) {
				properties.load(propFile);
				revision = properties.getProperty("git.commit.id.abbrev");
			}
		} catch (IOException e) {
			LOG.info("Cannot determine code revision. Unable ro read version property file.");
		}
		LOG.info("Starting Stratosphere JobManager (Version: " + version + ", Rev:" + revision + ")");
	}
8394
private static Manifest standardSoyJarManifest() {
    Manifest mf = new Manifest();
    mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
    mf.getMainAttributes().put(new Attributes.Name("Created-By"), "soy");
    return mf;
  }