Skip to content

Commit bebada3

Browse files
committed
Changed bash/sh commandline to exclude opening console when using start files.
1 parent ae23c5b commit bebada3

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/main/java/me/piitex/renjava/Main.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.piitex.renjava;
22

33
import org.apache.commons.io.IOUtils;
4-
import org.codehaus.plexus.archiver.tar.TarGZipUnArchiver;
54
import org.codehaus.plexus.archiver.util.DefaultFileSet;
65
import org.codehaus.plexus.archiver.zip.ZipArchiver;
76
import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
@@ -28,7 +27,6 @@ public static void main(String[] args) {
2827
System.out.println();
2928
System.out.println("The project uses the Amazon Corretto Java Distribution. By using this application you herby agree to all terms and conditions of using and distributing this software.");
3029
System.out.println();
31-
System.out.println();
3230
System.out.println("RenJava and all utilities and tools are maintained by piitex. Thank you for using the project.");
3331
System.out.println();
3432
System.out.println();
@@ -62,10 +60,12 @@ public static void main(String[] args) {
6260
}
6361

6462
void init() {
65-
String noc = "";
63+
String noc = ".exe";
64+
String command = "\"jdk\\windows\\bin\\java\"";
6665
if (noconsole) {
66+
command = "start jdk\\windows\\bin\\java";
6767
System.out.println("No console argument passed. Using 'javaw' command instead.");
68-
noc = "w";
68+
noc = "w.exe";
6969
}
7070

7171
System.out.println("Checking project environment...");
@@ -132,6 +132,9 @@ void init() {
132132
File savesDirectory = new File(gameDirectory, "/saves/");
133133
savesDirectory.mkdir();
134134

135+
File mediaDirectory = new File(gameDirectory, "/media/");
136+
mediaDirectory.mkdir();
137+
135138
System.out.println("Created game directory. Please place assets into the appropriate folders.");
136139

137140
System.out.println(artifact + "-" + version + ".jar");
@@ -207,7 +210,16 @@ void init() {
207210
File startBat = new File(workingDirectory, "start.bat");
208211
try {
209212
FileWriter writer = new FileWriter(startBat, false);
210-
writer.write("\"jdk\\windows\\bin\\java" + noc + ".exe\" -jar " + jarFile.getName());
213+
writer.write(command + noc + " -jar " + jarFile.getName());
214+
writer.close();
215+
} catch (IOException e) {
216+
throw new RuntimeException(e);
217+
}
218+
219+
File debugBat = new File(workingDirectory, "debug.bat");
220+
try {
221+
FileWriter writer = new FileWriter(debugBat, false);
222+
writer.write("\"jdk\\windows\\bin\\java.exe\" -jar HeroAdventure-1.0.1-SNAPSHOT.jar");
211223
writer.close();
212224
} catch (IOException e) {
213225
throw new RuntimeException(e);
@@ -254,6 +266,15 @@ void init() {
254266
}
255267
}
256268

269+
File debugSH = new File(workingDirectory, "debug.sh");
270+
try {
271+
FileWriter writer = new FileWriter(debugSH, false);
272+
writer.write("java -jar HeroAdventure-1.0.1-SNAPSHOT.jar");
273+
writer.close();
274+
} catch (IOException e) {
275+
throw new RuntimeException(e);
276+
}
277+
257278
System.out.println("Extracting GUI...");
258279
System.out.println("Setting color to " + color);
259280
// Check if the gui directory is empty
@@ -339,6 +360,12 @@ private void createDistributable(String os, File workingDirectory, File baseDir,
339360
// Delete logs folder
340361
deleteDirectory(new File(currentDistribution, "logs/"));
341362

363+
// Always delete debuggers
364+
File debugBat = new File(currentDistribution, "debug.bat");
365+
debugBat.delete();
366+
File debugSH = new File(currentDistribution, "debug.sh");
367+
debugSH.delete();
368+
342369

343370
if (os.equalsIgnoreCase("linux")) {
344371
File executable = Arrays.stream(currentDistribution.listFiles()).filter(file -> file.getName().endsWith(".exe")).findAny().orElse(null);

0 commit comments

Comments
 (0)