mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-02 06:24:03 +03:00
Direct main class
This commit is contained in:
parent
74449c194c
commit
ac4086856b
1 changed files with 4 additions and 7 deletions
|
@ -43,33 +43,30 @@ public void invoke(String... args) throws Exception {
|
||||||
String jarName = this.wrapper.commandHandler.readLine();
|
String jarName = this.wrapper.commandHandler.readLine();
|
||||||
Path jarPath = Paths.get(jarName);
|
Path jarPath = Paths.get(jarName);
|
||||||
|
|
||||||
String mainClassName;
|
|
||||||
String agentClassName;
|
String agentClassName;
|
||||||
|
|
||||||
try (JarFile file = new JarFile(jarPath.toFile())) {
|
try (JarFile file = new JarFile(jarPath.toFile())) {
|
||||||
LogHelper.info("Check server jar MainClass");
|
LogHelper.info("Check server jar MainClass");
|
||||||
mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class");
|
this.wrapper.config.mainclass = file.getManifest().getMainAttributes().getValue("Main-Class");
|
||||||
agentClassName = file.getManifest().getMainAttributes().getValue("Premain-Class");
|
agentClassName = file.getManifest().getMainAttributes().getValue("Premain-Class");
|
||||||
|
|
||||||
if (mainClassName == null) {
|
if (this.wrapper.config.mainclass == null) {
|
||||||
LogHelper.error("Main-Class not found in MANIFEST");
|
LogHelper.error("Main-Class not found in MANIFEST");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName(mainClassName, false, new PublicURLClassLoader(new URL[] { jarPath.toUri().toURL() }));
|
Class.forName(this.wrapper.config.mainclass, false, new PublicURLClassLoader(new URL[] { jarPath.toUri().toURL() }));
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogHelper.info("Found MainClass %s", mainClassName);
|
LogHelper.info("Found MainClass %s", this.wrapper.config.mainclass);
|
||||||
if (agentClassName != null)
|
if (agentClassName != null)
|
||||||
LogHelper.info("Found PremainClass %s", agentClassName);
|
LogHelper.info("Found PremainClass %s", agentClassName);
|
||||||
|
|
||||||
this.wrapper.config.mainclass = mainClassName;
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
if(!Request.isAvailable() || Request.getRequestService().isClosed()) {
|
if(!Request.isAvailable() || Request.getRequestService().isClosed()) {
|
||||||
LogHelper.info("Print websocket address (ws://host:port/api):");
|
LogHelper.info("Print websocket address (ws://host:port/api):");
|
||||||
|
|
Loading…
Reference in a new issue