private static string GetMainClassFromJarManifest(string mainClass) { JarFile jarFile = new JarFile(mainClass); string result; try { Manifest manifest = jarFile.getManifest(); if (manifest == null) { Console.Error.WriteLine("Jar file doesn't contain manifest"); result = null; return(result); } mainClass = manifest.getMainAttributes().getValue(java.util.jar.Attributes.Name.MAIN_CLASS); } finally { jarFile.close(); } if (mainClass == null) { Console.Error.WriteLine("Manifest doesn't contain a Main-Class."); result = null; } else { result = mainClass.Replace('/', '.'); } return(result); }
private static string GetMainClassFromJarManifest(string mainClass) { JarFile jf = new JarFile(mainClass); try { Manifest manifest = jf.getManifest(); if (manifest == null) { Console.Error.WriteLine("Jar file doesn't contain manifest"); return(null); } mainClass = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); } finally { jf.close(); } if (mainClass == null) { Console.Error.WriteLine("Manifest doesn't contain a Main-Class."); return(null); } return(mainClass.Replace('/', '.')); }