static Manifest getManifest() throws IOException { URL base = BeeLine.class.getResource("/META-INF/MANIFEST.MF"); URLConnection c = base.openConnection(); if (c instanceof JarURLConnection) { return ((JarURLConnection) c).getManifest(); } return null; }
public Manifest getManifest() throws Exception { URL url = this.getClass().getResource( BuildVersion.REFERENCE_FILE ); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); return jarConnection.getManifest(); } }
private static Manifest loadJarPluginManifest(final JarURLConnection connection, final Path jarPath) throws InvalidJarPluginException { try { return connection.getManifest(); } catch (IOException ex) { throw new InvalidJarPluginException("Manifest in JAR plugin specified is invalid: " + jarPath.toString(), ex); } }
/** * Returns the build date or {@code null} if not run from JAR. */ @Nullable private static String getBuildDate() { try { URL res = JLanguageTool.class.getResource(JLanguageTool.class.getSimpleName() + ".class"); if (res == null) { // this will happen on Android, see http://stackoverflow.com/questions/15371274/ return null; } Object connObj = res.openConnection(); if (connObj instanceof JarURLConnection) { JarURLConnection conn = (JarURLConnection) connObj; Manifest manifest = conn.getManifest(); return manifest.getMainAttributes().getValue("Implementation-Date"); } else { return null; } } catch (IOException e) { throw new RuntimeException("Could not get build date from JAR", e); } }
/** * Add the given URL to the classpath for this class loader, * caching the JAR file connection so it can be unloaded later * * @param file URL for the JAR file or directory to append to classpath */ public void addURLFile(URL file) { try { // open and cache JAR file connection URLConnection uc = file.openConnection(); if (uc instanceof JarURLConnection) { uc.setUseCaches(true); ((JarURLConnection) uc).getManifest(); cachedJarFiles.add((JarURLConnection)uc); } } catch (Exception e) { Log.warn("Failed to cache plugin JAR file: " + file.toExternalForm()); } addURL(file); }
manifest = embeddedJarUrlConnection.getManifest(); } catch (IOException ex) {
@Test public void testManifest() throws IOException { URL res = org.junit.Assert.class.getResource(org.junit.Assert.class.getSimpleName() + ".class"); JarURLConnection conn = (JarURLConnection) res.openConnection(); Manifest mf = conn.getManifest(); Attributes atts = mf.getMainAttributes(); for (Object v : atts.values()) { System.out.println(v); } }
@Override public Manifest getManifest() throws IOException { try { return super.getManifest(); } finally { this.connected = false; } }
@Override public Manifest getManifest() throws IOException { return jarURLConnection.getManifest(); }
@Override public Manifest getManifest() throws IOException { return jarURLConnection.getManifest(); }
static Manifest getManifest() throws IOException { URL base = BeeLine.class.getResource("/META-INF/MANIFEST.MF"); URLConnection c = base.openConnection(); if (c instanceof JarURLConnection) { return ((JarURLConnection) c).getManifest(); } return null; }
static Manifest getManifest() throws IOException { URL base = SqlLine.class.getResource("/META-INF/MANIFEST.MF"); URLConnection c = base.openConnection(); if (c instanceof JarURLConnection) { return ((JarURLConnection) c).getManifest(); } return null; }
static Manifest getManifest() throws IOException { URL base = SqlLine.class.getResource("/META-INF/MANIFEST.MF"); URLConnection c = base.openConnection(); if (c instanceof JarURLConnection) { return ((JarURLConnection) c).getManifest(); } return null; }
static Manifest getManifest() throws IOException { URL base = BeeLine.class.getResource("/META-INF/MANIFEST.MF"); URLConnection c = base.openConnection(); if (c instanceof JarURLConnection) { return ((JarURLConnection) c).getManifest(); } return null; }
static Manifest getManifest() throws IOException { URL base = BeeLine.class.getResource("/META-INF/MANIFEST.MF"); URLConnection c = base.openConnection(); if (c instanceof JarURLConnection) { return ((JarURLConnection) c).getManifest(); } return null; }
private Optional<Manifest> findManifest(URLConnection urlConnection) { try { if (urlConnection instanceof JarURLConnection) { return Optional.ofNullable(((JarURLConnection) urlConnection).getManifest()); } } catch (IOException e) { // noop } return Optional.empty(); }
/** Return manifest from JAR file. * @param classPath path to class in JAR file. * @throws IOException */ private static Manifest getManifestFromJar(String classPath) throws IOException { URL url = new URL(classPath); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); return jarConnection.getManifest(); }
String className = getClass().getSimpleName() + ".class"; String classPath = getClass().getResource(className).toString(); if (!classPath.startsWith("jar")) { return DEFAULT_PROPERTY_VALUE; } URL url = new URL(classPath); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); Manifest manifest = jarConnection.getManifest(); Attributes attributes = manifest.getMainAttributes(); return attributes.getValue(PROPERTY_NAME);
String className = getClass().getSimpleName() + ".class"; String classPath = getClass().getResource(className).toString(); if (!classPath.startsWith("jar")) { return DEFAULT_PROPERTY_VALUE; } URL url = new URL(classPath); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); Manifest manifest = jarConnection.getManifest(); Attributes attributes = manifest.getMainAttributes(); return attributes.getValue(PROPERTY_NAME);
private Attributes getMyManifestAttributes() throws IOException { String className = getClass().getSimpleName() + ".class"; String classPath = getClass().getResource(className).toString(); if (!classPath.startsWith("jar")) { throw new IOException("I don't live in a jar file"); } URL url = new URL(classPath); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); Manifest manifest = jarConnection.getManifest(); return manifest.getMainAttributes(); }