Skip to content

Commit

Permalink
Merge pull request #14 from HackusatePvP/experimental
Browse files Browse the repository at this point in the history
RenJavaLauncher Fix
  • Loading branch information
HackusatePvP committed May 7, 2024
2 parents 1284329 + 8a543a2 commit cfb791d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/me/piitex/renjava/Launch.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -78,11 +79,27 @@ private static void loadClass(Class<?> clazz, String[] args) {
file.createNewFile();
}

String jarPath = Launch.class
.getProtectionDomain()
.getCodeSource()
.getLocation()
.toURI()
.getPath();

System.out.println("Path: " + jarPath);

String[] split = jarPath.split("/");
String fileName = split[split.length - 1];

FileWriter writer = new FileWriter(file);
writer.append("main=").append(clazz.getName());
writer.append("\n");
writer.write("file=" + fileName);
writer.close();
} catch (IOException e) {
System.err.println("Could not create the 'build.info' file. This might be a first time setup. Once the application opens please exit and relaunch.");
} catch (URISyntaxException e) {
System.err.println("Could retrieve runtime information.");
}


Expand Down

0 comments on commit cfb791d

Please sign in to comment.