Attributes attributes = jarURLConnection.getMainAttributes(); if (attributes != null) { String implementationTitle = attributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
@Override public Attributes getMainAttributes() throws IOException { return jarURLConnection.getMainAttributes(); }
@Override public Attributes getMainAttributes() throws IOException { return jarURLConnection.getMainAttributes(); }
@Override public Attributes getMainAttributes() throws IOException { return jarURLConnection.getMainAttributes(); }
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; }
/** * Retrieves the manifest attributes of the JAR from which this file is * running. * * @return the manifest attributes of the JAR from which this class is running * @throws Exception if unable to retrieve the JAR resource for a class */ private static Attributes retrieveManifestAttributes() throws Exception { // get the name of this class with all the "."s replaced with "/"s String className = Bootstrap.class.getName().replace('.', '/'); // create a new URL pointing to the resource representing this class URL classURL = ClassLoader.getSystemResource(className + ".class"); // throw an error if we could not get it if (classURL == null) { throw new Exception("Unable to retrieve JAR resource for " + className); } // end if // open a connection to the class resource URLConnection urlConn = classURL.openConnection(); // make sure that we're executing from within a JAR if ( (urlConn == null) || ! (urlConn instanceof JarURLConnection)) { throw new Exception("Bootstrap class must be executed from within a JAR"); } // end if // return its manifest attributes return ( (JarURLConnection) urlConn).getMainAttributes(); }
public void executeJar(String jarFileName, String[] args) throws ClassNotFoundException, NoSuchMethodException { // add jar to class path classLoader.addJarClassPathElement(jarFileName); // get class name from MANIFEST String className = null; try { URL u = new URL("jar:file:" + jarFileName + "!/"); JarURLConnection uc = (JarURLConnection) u.openConnection(); Attributes attr = uc.getMainAttributes(); if (attr != null) { className = attr.getValue(Attributes.Name.MAIN_CLASS); } } catch (IOException ioe) { } if (className == null) { System.err.println("No " + Attributes.Name.MAIN_CLASS + " specified in jar file " + jarFileName); // NOPMD by xlv } else { run(className, args); } }
attributes = jc.getMainAttributes(); } catch (IOException e) {
attributes = jc.getMainAttributes(); } catch (IOException e) {
attributes = jc.getMainAttributes(); } catch (IOException e) {
attributes = jc.getMainAttributes(); } catch (IOException e) {
JarURLConnection jcl = (JarURLConnection) fetchUrl.toUri().toURL().openConnection(); Attributes attr = jcl.getMainAttributes(); String mainClass = (attr != null) ? attr.getValue(Attributes.Name.MAIN_CLASS) : null; if (mainClass != null) {
URLConnection conn = resource.openConnection(); if(conn instanceof JarURLConnection) { Attributes mainAttributes = ((JarURLConnection) conn).getMainAttributes(); String clsName = mainAttributes.getValue("X-Rascal-Saved-Class"); if(clsName == null)