mirror of
https://github.com/kuroppoi/entralinked.git
synced 2026-10-01 20:06:42 -05:00
Copy libraries to working directory instead of obscure temp location
This commit is contained in:
@@ -3,8 +3,6 @@ package entralinked;
|
||||
import java.io.File;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -27,12 +25,19 @@ public class LauncherAgent {
|
||||
"bcpkix-jdk15on-1.70.jar"
|
||||
};
|
||||
|
||||
// Try create library directory
|
||||
File libraryDirectory = new File("libs");
|
||||
libraryDirectory.mkdirs();
|
||||
|
||||
// Extract jars if necessary
|
||||
for(int i = 0; i < jarNames.length; i++) {
|
||||
String jarName = jarNames[i];
|
||||
Path jarPath = Files.createTempFile(jarNames[i], null);
|
||||
File jarFile = jarPath.toFile();
|
||||
jarFile.deleteOnExit(); // Doesn't actually do anything on terminal exit because Java.
|
||||
Files.copy(LauncherAgent.class.getResourceAsStream("/%s".formatted(jarName)), jarPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
File jarFile = new File(libraryDirectory, jarName);
|
||||
|
||||
if(!jarFile.exists()) {
|
||||
Files.copy(LauncherAgent.class.getResourceAsStream("/%s".formatted(jarName)), jarFile.toPath());
|
||||
}
|
||||
|
||||
instrumentation.appendToSystemClassLoaderSearch(new JarFile(jarFile));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user