[ANY] Setup "jar filename" - specify for what (#385)

This commit is contained in:
sasha0552 2020-04-24 23:32:08 +06:00 committed by GitHub
parent ac64ec5483
commit a71b62ca1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,14 +25,14 @@ public ServerWrapperSetup() throws IOException {
public void run() throws IOException { public void run() throws IOException {
ServerWrapper wrapper = ServerWrapper.wrapper; ServerWrapper wrapper = ServerWrapper.wrapper;
ServerWrapper.modulesManager.invokeEvent(new ServerWrapperPreSetupEvent(this)); ServerWrapper.modulesManager.invokeEvent(new ServerWrapperPreSetupEvent(this));
System.out.println("Print jar filename:"); System.out.println("Print server jar filename:");
String jarName = commands.commandHandler.readLine(); String jarName = commands.commandHandler.readLine();
Path jarPath = Paths.get(jarName); Path jarPath = Paths.get(jarName);
String mainClassName; String mainClassName;
try (JarFile file = new JarFile(jarPath.toFile())) { try (JarFile file = new JarFile(jarPath.toFile())) {
URL jarURL = jarPath.toUri().toURL(); URL jarURL = jarPath.toUri().toURL();
urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL}); urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL});
LogHelper.info("Check jar MainClass"); LogHelper.info("Check server jar MainClass");
mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class"); mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class");
if (mainClassName == null) { if (mainClassName == null) {
LogHelper.error("Main-Class not found in MANIFEST"); LogHelper.error("Main-Class not found in MANIFEST");