Skip to content

Commit 6dea31e

Browse files
committed
Version 2.0.2
1 parent a1ee7ef commit 6dea31e

File tree

5 files changed

+54
-26
lines changed

5 files changed

+54
-26
lines changed

InnoSetup Installer/64Bit-GraalVM-Installer.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "GraalVM Installer"
5-
#define MyAppVersion "2.0.1"
5+
#define MyAppVersion "2.0.2"
66
#define MyAppPublisher "SourceRabbit"
77
#define MyAppURL "https://www.sourcerabbit.com/"
88
#define MyAppExeName "GraalVMInstaller.exe"

NetBeans Project/src/graalvminstallerforwindows/Core/Installer.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Installer
3636
private final String fDownloadURL, fInstallationPath;
3737
private final String fDownloadedZipFilePath;
3838
private final FileUtils fFileUtils;
39+
private boolean fEnvironmentVariablesAreSet = false;
3940

4041
public Installer(String downloadURL, String installationPath)
4142
{
@@ -151,12 +152,33 @@ public boolean accept(File current, String name)
151152

152153
private boolean STEP5_SetJavaHomePathAndRunJarFix() throws Exception
153154
{
154-
try
155+
156+
UITools.ShowPleaseWaitDialog("Please wait", "Setting Environment variables...", frmMain.fInstance, () ->
155157
{
156-
EnvironmentVariablesManager.SetEnvironmentVariable("JAVA_HOME", fInstallationPath);
157-
EnvironmentVariablesManager.AddEnvironmentVariable("PATH", fInstallationPath + "\\bin");
158-
}
159-
catch (Exception ex)
158+
try
159+
{
160+
EnvironmentVariablesManager.SetEnvironmentVariable("JAVA_HOME", fInstallationPath);
161+
EnvironmentVariablesManager.AddEnvironmentVariable("PATH", fInstallationPath + "\\bin\\");
162+
fEnvironmentVariablesAreSet = true;
163+
}
164+
catch (Exception ex)
165+
{
166+
fEnvironmentVariablesAreSet = false;
167+
return;
168+
}
169+
170+
try
171+
{
172+
// Wait 2 seconds before run JarFix
173+
Thread.sleep(2000);
174+
}
175+
catch (Exception ex)
176+
{
177+
178+
}
179+
});
180+
181+
if (!fEnvironmentVariablesAreSet)
160182
{
161183
throw new Exception("Cannot set environment variables!");
162184
}
@@ -172,7 +194,7 @@ private boolean STEP5_SetJavaHomePathAndRunJarFix() throws Exception
172194
// Run jarfix.exe
173195
final String userDir = System.getProperty("user.dir");
174196
String jarFixRunCommand = userDir + "\\Prerequisites\\jarfix.exe";
175-
DosPromt.ExecuteDOSPromt(jarFixRunCommand);
197+
DosPromt.ExecuteDosPromtAndWaitToFinish(jarFixRunCommand);
176198
}
177199
catch (IOException ex)
178200
{

NetBeans Project/src/graalvminstallerforwindows/Core/Settings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
public class Settings
2222
{
2323

24-
public static final String fAppVersion = "2.0.1";
24+
public static final String fAppVersion = "2.0.2";
2525
public static final String fDownloadsListFile = "https://raw.githubusercontent.com/SourceRabbit/GraalVM-Windows-Installer/main/Downloads/DownloadsList.txt";
2626
}

NetBeans Project/src/graalvminstallerforwindows/Core/Utilities/DosPromt.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public class DosPromt
2525
{
2626

27-
public static String ExecuteDOSPromt(String command) throws IOException
27+
public static String ExecuteDOSPromtAndGetResult(String command) throws IOException
2828
{
2929
String result = "";
3030
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", command);
@@ -44,4 +44,11 @@ public static String ExecuteDOSPromt(String command) throws IOException
4444

4545
return result;
4646
}
47+
48+
public static void ExecuteDosPromtAndWaitToFinish(String command) throws InterruptedException, IOException
49+
{
50+
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", command);
51+
Process p = builder.start();
52+
int exitVal = p.waitFor();
53+
}
4754
}
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package graalvminstallerforwindows.Core.Utilities;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54
import java.util.stream.Collectors;
65

76

@@ -24,39 +23,39 @@
2423
*/
2524
public class EnvironmentVariablesManager
2625
{
27-
26+
2827
public EnvironmentVariablesManager()
2928
{
30-
29+
3130
}
32-
31+
3332
public static void SetEnvironmentVariable(String variable, String value) throws Exception
3433
{
35-
final String dosCommand = "setx " + variable + " \"" + value + ";" + "\"";
36-
DosPromt.ExecuteDOSPromt(dosCommand);
37-
34+
final String dosCommand = "setx /M " + variable + " \"" + value + "\"";
35+
DosPromt.ExecuteDosPromtAndWaitToFinish(dosCommand);
3836
}
39-
37+
4038
public static void AddEnvironmentVariable(String variable, String value) throws Exception
4139
{
42-
final String[] currentValues = DosPromt.ExecuteDOSPromt("echo %" + variable + "%").split(";");
40+
final String[] currentValues = DosPromt.ExecuteDOSPromtAndGetResult("echo %" + variable + "%").split(";");
4341

44-
// C:\Development\GraalVM-Windows-Installer\NetBeans Project\00_Release\jre\bin
45-
final String userDir = System.getProperty("user.dir");
42+
final String appPath = System.getProperty("user.dir");
4643
ArrayList<String> finalValues = new ArrayList<>();
4744
for (String s : currentValues)
4845
{
49-
if (!s.equals("null") && !s.equals("") && !s.equals(value) && !finalValues.contains(s) && !s.startsWith(userDir))
46+
if (!s.equals("null") && !s.equals("") && !s.equals(value) && !finalValues.contains(s) && !s.startsWith(appPath) && !s.contains("\""))
5047
{
5148
finalValues.add(s);
5249
}
5350
}
5451
finalValues.add(value);
55-
56-
final String newValuesString = finalValues.stream().collect(Collectors.joining(";"));
5752

58-
//final String currentVariableValuesString = System.getenv(variable);
59-
SetEnvironmentVariable(variable, newValuesString);
53+
// CAUTION -- ADD ';' at the end!
54+
final String newValuesString = finalValues.stream().collect(Collectors.joining(";")) + ";";
55+
56+
final String dosCommand = "setx /M " + variable + " \"" + newValuesString + "\"";
57+
DosPromt.ExecuteDosPromtAndWaitToFinish(dosCommand);
58+
6059
}
61-
60+
6261
}

0 commit comments

Comments
 (0)