Skip to content

Commit 7efb884

Browse files
committed
add support for winrun4j 32-bit exe and refactoring
1 parent 046c53d commit 7efb884

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/main/java/io/github/fvarrui/javapackager/packagers/CreateWindowsExeWinRun4j.java

+16-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.apache.commons.lang3.StringUtils;
1111

12+
import io.github.fvarrui.javapackager.model.Arch;
1213
import io.github.fvarrui.javapackager.model.Platform;
1314
import io.github.fvarrui.javapackager.model.WindowsConfig;
1415
import io.github.fvarrui.javapackager.model.WindowsExeCreationTool;
@@ -57,7 +58,8 @@ protected File doApply(WindowsPackager packager) throws Exception {
5758
File jreDestinationFolder = packager.getJreDestinationFolder();
5859
boolean bundleJre = packager.getBundleJre();
5960
String vmLocation = packager.getWinConfig().getVmLocation();
60-
WindowsConfig winConfig = packager.getWinConfig();
61+
WindowsConfig winConfig = packager.getWinConfig();
62+
Arch arch = packager.getArch();
6163

6264
if (winConfig.isWrapJar()) {
6365
Logger.warn("'wrapJar' property ignored when building EXE with " + getArtifactName());
@@ -72,7 +74,11 @@ protected File doApply(WindowsPackager packager) throws Exception {
7274
FileUtils.copyFileToFile(iconFile, getGenericIcon());
7375

7476
// creates generic exe
75-
FileUtils.copyResourceToFile("/windows/WinRun4J64.exe", getGenericExe());
77+
if (arch == Arch.x64) {
78+
FileUtils.copyResourceToFile("/windows/WinRun4J64.exe", getGenericExe());
79+
} else if (arch == Arch.x86) {
80+
FileUtils.copyResourceToFile("/windows/WinRun4J.exe", getGenericExe());
81+
}
7682

7783
// uses vmLocation only if a JRE is bundled
7884
if (bundleJre) {
@@ -89,7 +95,7 @@ protected File doApply(WindowsPackager packager) throws Exception {
8995

9096
} else {
9197

92-
// searchs for valid jvm.dll file in JRE
98+
// searchs for a valid jvm.dll file in JRE
9399
Optional<File> jvmDllFile = Arrays.asList(JVM_DLL_PATHS)
94100
.stream()
95101
.map(path -> new File(jreDestinationFolder, path))
@@ -115,11 +121,6 @@ protected File doApply(WindowsPackager packager) throws Exception {
115121

116122
}
117123

118-
// generates ini file
119-
File genericIni = new File(getOutputFolder(), "app.ini");
120-
VelocityUtils.render("windows/ini.vtl", genericIni, packager);
121-
Logger.info("INI file generated in " + genericIni.getAbsolutePath() + "!");
122-
123124
// set exe metadata with rcedit
124125
RcEdit rcedit = new RcEdit(getOutputFolder());
125126
rcedit.setIcon(getGenericExe(), getGenericIcon());
@@ -136,6 +137,7 @@ protected File doApply(WindowsPackager packager) throws Exception {
136137
FileUtils.copyFileToFolder(jarFile, appFolder);
137138

138139
// copies winrun4j launcher helper library (needed to work around
140+
/*
139141
File winrun4jJar = new File(libsFolder, "winrun4j-launcher.jar");
140142
FileUtils.copyResourceToFile("/windows/winrun4j-launcher.jar", winrun4jJar);
141143
@@ -147,7 +149,13 @@ protected File doApply(WindowsPackager packager) throws Exception {
147149
148150
// copies winrun4j properties to launcher jar
149151
JarUtils.addFileToJar(winrun4jJar, propertiesFile);
152+
*/
150153

154+
// generates ini file
155+
File genericIni = new File(getOutputFolder(), "app.ini");
156+
VelocityUtils.render("windows/ini.vtl", genericIni, packager);
157+
Logger.info("INI file generated in " + genericIni.getAbsolutePath() + "!");
158+
151159
// copies ini file to app folder
152160
File iniFile = new File(appFolder, name + ".ini");
153161
FileUtils.copyFileToFile(genericIni, iniFile);
60 KB
Binary file not shown.

src/main/resources/windows/ini.vtl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
main.class=WinRun4JLauncher
1+
main.class=${info.mainClass}
22
log.level=error
33
ini.override=true
44
classpath.1=libs\*.jar
@@ -10,6 +10,8 @@ classpath.${classpathCounter}=$!{cp}
1010
#end
1111
#if ($info.bundleJre)
1212
vm.location=${info.jreDirectoryName}\\${info.winConfig.vmLocation}
13+
#else
14+
vm.location=%JAVA_HOME%\bin\client\jvm.dll|%JAVA_HOME%\bin\server\jvm.dll
1315
#end
1416
#if (!$info.bundleJre && $info.jreMinVersion)
1517
vm.version.min=${info.jreMinVersion}

0 commit comments

Comments
 (0)