Example usage for java.net JarURLConnection getMainAttributes

List of usage examples for java.net JarURLConnection getMainAttributes

Introduction

In this page you can find the example usage for java.net JarURLConnection getMainAttributes.

Prototype

public Attributes getMainAttributes() throws IOException 

Source Link

Document

Returns the main Attributes for the JAR file for this connection.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    URL url = new URL("jar:file:/c://my.jar!/");
    JarURLConnection conn = (JarURLConnection) url.openConnection();

    Attributes attrs = conn.getMainAttributes();
    System.out.println(attrs.isEmpty());
}

From source file:JarClassLoader.java

public String getMainClassName() throws IOException {
    URL u = new URL("jar", "", url + "!/");
    JarURLConnection uc = (JarURLConnection) u.openConnection();
    Attributes attr = uc.getMainAttributes();
    return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
}

From source file:org.hyperic.util.PluginLoader.java

public static String getPluginMainClass(URL url) throws Exception {

    JarURLConnection jarConn = (JarURLConnection) url.openConnection();
    Attributes attrs = jarConn.getMainAttributes();

    String pluginName = attrs.getValue(Attributes.Name.MAIN_CLASS);

    return pluginName;
}