Tabnine Logo
Manifest
Code IndexAdd Tabnine to your IDE (free)

How to use
Manifest
in
java.util.jar

Best Java code snippets using java.util.jar.Manifest (Showing top 20 results out of 10,872)

Refine searchRefine arrow

  • Attributes
  • URL
  • JarFile
  • Attributes.Name
  • InputStream
  • Jar
  • Enumeration
origin: skylot/jadx

  public static String getVersion() {
    try {
      ClassLoader classLoader = Jadx.class.getClassLoader();
      if (classLoader != null) {
        Enumeration<URL> resources = classLoader.getResources("META-INF/MANIFEST.MF");
        while (resources.hasMoreElements()) {
          Manifest manifest = new Manifest(resources.nextElement().openStream());
          String ver = manifest.getMainAttributes().getValue("jadx-version");
          if (ver != null) {
            return ver;
          }
        }
      }
    } catch (Exception e) {
      LOG.error("Can't get manifest file", e);
    }
    return "dev";
  }
}
origin: Sable/soot

private void addManifest(ZipOutputStream destination, Collection<File> dexFiles) throws IOException {
 final Manifest manifest = new Manifest();
 manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
 manifest.getMainAttributes().put(new Attributes.Name("Created-By"), "Soot Dex Printer");
 if (dexFiles != null && !dexFiles.isEmpty()) {
  manifest.getMainAttributes().put(new Attributes.Name("Dex-Location"),
    dexFiles.stream().map(File::getName).collect(Collectors.joining(" ")));
 }
 final ZipEntry manifestEntry = new ZipEntry(JarFile.MANIFEST_NAME);
 destination.putNextEntry(manifestEntry);
 manifest.write(new BufferedOutputStream(destination));
 destination.closeEntry();
}
origin: pxb1988/dex2jar

Manifest input = jar.getManifest();
Manifest output = new Manifest();
Attributes main = output.getMainAttributes();
if (input != null) {
  main.putAll(input.getMainAttributes());
main.putValue("Manifest-Version", "1.0");
main.putValue("Created-By", "1.6.0_21 (d2j-" + AbstractJarSign.class.getPackage().getImplementationVersion() + ")");
for (Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements();) {
  JarEntry entry = e.nextElement();
  byName.put(entry.getName(), entry);
  String name = entry.getName();
  if (!entry.isDirectory() && !name.equals(JarFile.MANIFEST_NAME) && !stripPattern.matcher(name).matches()) {
    InputStream data = jar.getInputStream(entry);
    while ((num = data.read(buffer)) > 0) {
      md.update(buffer, 0, num);
      attr = input.getAttributes(name);
    attr = attr != null ? new Attributes(attr) : new Attributes();
    attr.putValue(digName, encodeBase64(md.digest()));
    output.getEntries().put(name, attr);
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public File toJar(File file) throws IOException {
  Manifest manifest = new Manifest();
  manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION);
  return toJar(file, manifest);
}
origin: robovm/robovm

private boolean isSealed(Manifest manifest, String dirName) {
  Attributes attributes = manifest.getAttributes(dirName);
  if (attributes != null) {
    String value = attributes.getValue(Attributes.Name.SEALED);
    if (value != null) {
      return value.equalsIgnoreCase("true");
    }
  }
  Attributes mainAttributes = manifest.getMainAttributes();
  String value = mainAttributes.getValue(Attributes.Name.SEALED);
  return (value != null && value.equalsIgnoreCase("true"));
}
origin: Netflix/eureka

private static Manifest loadManifest(String jarUrl) throws Exception {
  InputStream is = new URL(jarUrl + "!/META-INF/MANIFEST.MF").openStream();
  try {
    return new Manifest(is);
  } finally {
    is.close();
  }
}
origin: stackoverflow.com

 JarFile jar = new JarFile(new File("path/to/your/jar-file"));
InputStream is = jar.getInputStream(jar.getEntry("META-INF/MANIFEST.MF"));
Manifest man = new Manifest(is);
is.close();
for(Map.Entry<String, Attributes> entry: man.getEntries().entrySet()) {
  for(Object attrkey: entry.getValue().keySet()) {
    if (attrkey instanceof Attributes.Name && 
      ((Attributes.Name)attrkey).toString().indexOf("-Digest") != -1)
      signed.add(entry.getKey());
for(Enumeration<JarEntry> entry = jar.entries(); entry.hasMoreElements(); ) {
  JarEntry je = entry.nextElement();
  if (!je.isDirectory())
    entries.add(je.getName());
origin: stackoverflow.com

 Enumeration<URL> resources = getClass().getClassLoader()
 .getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
  try {
   Manifest manifest = new Manifest(resources.nextElement().openStream());
   // check that this is your manifest and do what you need or get the next one
   ...
  } catch (IOException E) {
   // handle
  }
}
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public Manifest getManifest() throws IOException {
  File file = new File(folder, JarFile.MANIFEST_NAME);
  if (file.exists()) {
    InputStream inputStream = new FileInputStream(file);
    try {
      return new Manifest(inputStream);
    } finally {
      inputStream.close();
    }
  } else {
    return NO_MANIFEST;
  }
}
origin: redisson/redisson

try {
  try {
    Manifest manifest = new Manifest(inputStream);
    Map<Attributes.Name, String> values = new HashMap<Attributes.Name, String>();
    Attributes mainAttributes = manifest.getMainAttributes();
    if (mainAttributes != null) {
      for (Attributes.Name attributeName : ATTRIBUTE_NAMES) {
        values.put(attributeName, mainAttributes.getValue(attributeName));
    Attributes attributes = manifest.getAttributes(packageName.replace('.', '/').concat("/"));
    if (attributes != null) {
      for (Attributes.Name attributeName : ATTRIBUTE_NAMES) {
        String value = attributes.getValue(attributeName);
        if (value != null) {
          values.put(attributeName, value);
            : NOT_SEALED);
  } finally {
    inputStream.close();
origin: jenkinsci/jenkins

URL sealBase = null;
Attributes sectionAttributes = manifest.getAttributes(sectionName);
if (sectionAttributes != null) {
  specificationTitle = sectionAttributes.getValue(Name.SPECIFICATION_TITLE);
  specificationVendor = sectionAttributes.getValue(Name.SPECIFICATION_VENDOR);
  specificationVersion = sectionAttributes.getValue(Name.SPECIFICATION_VERSION);
  implementationTitle = sectionAttributes.getValue(Name.IMPLEMENTATION_TITLE);
  implementationVendor = sectionAttributes.getValue(Name.IMPLEMENTATION_VENDOR);
  sealedString = sectionAttributes.getValue(Name.SEALED);
Attributes mainAttributes = manifest.getMainAttributes();
if (mainAttributes != null) {
  if (specificationTitle == null) {
    sealBase = new URL(FileUtils.getFileUtils().toURI(container.getAbsolutePath()));
  } catch (MalformedURLException e) {
origin: pxb1988/dex2jar

int num;
Map<String, Attributes> entries = manifest.getEntries();
List<String> names = new ArrayList<>(entries.keySet());
Collections.sort(names);
for (String name : names) {
  JarEntry inEntry = in.getJarEntry(name);
  JarEntry outEntry = null;
  if (inEntry.getMethod() == JarEntry.STORED) {
  out.putNextEntry(outEntry);
  InputStream data = in.getInputStream(inEntry);
  while ((num = data.read(buffer)) > 0) {
    out.write(buffer, 0, num);
origin: jenkinsci/jenkins

protected String identifyPluginShortName(File t) {
  try {
    JarFile j = new JarFile(t);
    try {
      String name = j.getManifest().getMainAttributes().getValue("Short-Name");
      if (name!=null) return name;
    } finally {
      j.close();
    }
  } catch (IOException e) {
    LOGGER.log(WARNING, "Failed to identify the short name from "+t,e);
  }
  return FilenameUtils.getBaseName(t.getName());    // fall back to the base name of what's uploaded
}
origin: biz.aQute/bndlib

public Manifest getManifest() throws Exception {
  check();
  if (manifest == null) {
    Resource manifestResource = getResource("META-INF/MANIFEST.MF");
    if (manifestResource != null) {
      InputStream in = manifestResource.openInputStream();
      manifest = new Manifest(in);
      in.close();
    }
  }
  return manifest;
}
origin: google/guava

  manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH.toString());
if (classpathAttribute != null) {
 for (String path : CLASS_PATH_ATTRIBUTE_SEPARATOR.split(classpathAttribute)) {
   continue;
  if (url.getProtocol().equals("file")) {
   builder.add(toFile(url));
origin: stackoverflow.com

 URLClassLoader cl = (URLClassLoader) getClass().getClassLoader();
try {
 URL url = cl.findResource("META-INF/MANIFEST.MF");
 Manifest manifest = new Manifest(url.openStream());
 // do stuff with it
 ...
} catch (IOException E) {
 // handle
}
origin: jenkinsci/jenkins

/*package*/ static @CheckForNull Manifest parsePluginManifest(URL bundledJpi) {
  try {
    URLClassLoader cl = new URLClassLoader(new URL[]{bundledJpi});
    InputStream in=null;
    try {
      URL res = cl.findResource(PluginWrapper.MANIFEST_FILENAME);
      if (res!=null) {
        in = getBundledJpiManifestStream(res);
        Manifest manifest = new Manifest(in);
        return manifest;
      }
    } finally {
      Util.closeAndLogFailures(in, LOGGER, PluginWrapper.MANIFEST_FILENAME, bundledJpi.toString());
      if (cl instanceof Closeable)
        ((Closeable)cl).close();
    }
  } catch (IOException e) {
    LOGGER.log(WARNING, "Failed to parse manifest of "+bundledJpi, e);
  }
  return null;
}

origin: jenkinsci/jenkins

private String getVersionOf(Manifest manifest) {
  String v = manifest.getMainAttributes().getValue("Plugin-Version");
  if(v!=null)      return v;
  // plugins generated before maven-hpi-plugin 1.3 should still have this attribute
  v = manifest.getMainAttributes().getValue("Implementation-Version");
  if(v!=null)      return v;
  return "???";
}
origin: org.apache.felix/maven-bundle-plugin

private boolean isOsgi( Jar jar ) throws Exception
{
  if ( jar.getManifest() != null )
  {
    return jar.getManifest().getMainAttributes().getValue( Analyzer.BUNDLE_NAME ) != null;
  }
  return false;
}
origin: gocd/gocd

  private static String defaultMainClassName(JarFile jarFile) throws IOException {
    return jarFile.getManifest().getMainAttributes().getValue("GoCD-Main-Class");
  }
}
java.util.jarManifest

Javadoc

The Manifest class is used to obtain attribute information for a JarFile and its entries.

Most used methods

  • getMainAttributes
    Returns the main Attributes of the JarFile.
  • <init>
    Creates a new Manifest instance. The new instance will have the same attributes as those found in th
  • write
    Writes out the attribute information of the specified manifest to the specified OutputStream
  • getAttributes
    Returns the Attributes associated with the parameter entry name.
  • getEntries
    Returns a map containing the Attributes for each entry in the Manifest.
  • read
    Merges name/attribute pairs read from the input stream is into this manifest.
  • exposeByteArrayInputStreamBytes
    Returns a byte[] containing all the bytes from a ByteArrayInputStream. Where possible, this returns
  • writeEntry
  • clone
    Creates a copy of this Manifest. The returned Manifestwill equal the Manifest from which it was clon
  • getChunk
  • getMainAttributesEnd
  • removeChunks
  • getMainAttributesEnd,
  • removeChunks,
  • clear,
  • equals,
  • hashCode

Popular in Java

  • Finding current android device location
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now