Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to create a 32-bit native Windows installer in a 64-bit Maven build process JVM (and vice versa) #81

Closed
aliebelt opened this issue Dec 3, 2014 · 26 comments

Comments

@aliebelt
Copy link

aliebelt commented Dec 3, 2014

Hi,

we want to create two different native installers in one Maven build process: for Windows 64-bit and 32-bit. We execute Maven with a 64-bit JRE.

So we have two executions for the javafx-maven-plugin, one with a 64-bit JRE-path specified as runtime and one execution with a 32-bit JRE-path.

The 64-bit installer is created unproblematically, but when building the 32-bit installer following warning is printed and the 32-bit installer creation process is canceled:
Bundler EXE Installer skipped because of a configuration problem:Bit architecture mismatch between FX SDK and JRE runtime.Advice to fix: Make sure to use JRE runtime with correct bit architecture.

We think it's an important ability of an installer-creator to create both, 32-bit and 64-bit installer in one build process (e.g. mvn clean release:prepare release:perform).

Best regards

@FibreFoX
Copy link
Member

FibreFoX commented Jan 9, 2015

Found some things on the net:
http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javapackager.html#BGBDJIGE
http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javafxpackager.html
http://stackoverflow.com/questions/24025309/javafxpackager-how-do-you-set-the-base-jdk

If I understand correctly, this should create a 32/64-bit installer depending in the selected JRE by using <jvmArgs /> with the -Bruntime= parameter

Its also suggested by oracle (but it was for jdk 7): https://community.oracle.com/thread/3569519 and https://community.oracle.com/thread/2455678

Maybe this helps (didnt try it myself)?

@FibreFoX
Copy link
Member

Hi @aliebelt ,

i added support for multiple executions, could you retry with current master if it works for you when setting jvmArgs to 32bit/64bit JRE?

@aliebelt
Copy link
Author

Hi Danny, I'm wondering how a jvmArg can help for a native Windows installer (self-contained application)? Because there is a 32 bit OR a 64 bit JRE containted in the installation directory and I don't think that a jvmArg can change something.

@aliebelt
Copy link
Author

Do you meen to duplicate the configuration, extract to two excecution statements and change the runtime? Something like that:

<executions>
    <execution>
        <id>create-installer-for-windows-64-bit</id>
        <configuration>
            <bundleArguments>
                <runtime>${jre-64-bit-path}</runtime>
            </bundleArguments>
        </configuration>
    </execution>
    <execution>
        <id>create-installer-for-windows-32-bit</id>
        <configuration>
            <bundleArguments>
                <runtime>${jre-32-bit-path}</runtime>
            </bundleArguments>
        </configuration>
    </execution>
</executions>

@FibreFoX
Copy link
Member

Yes, i had two executions in mind.

@aliebelt
Copy link
Author

I executed it with Maven and JDK 8u40 64bit. The 64-bit -configuration builds the native installer. When executing the 32-bit-configuration of the javafx-maven-plugin it is skipped:

[INFO] Skipping Windows Application Image because of configuration error Bit architecture mismatch between FX SDK and JRE runtime.
Advice to Fix: Make sure to use JRE runtime with correct bit architecture.
[INFO] Skipping EXE Installer because of configuration error Bit architecture mismatch between FX SDK and JRE runtime.
Advice to Fix: Make sure to use JRE runtime with correct bit architecture.

This is likely not a problem of the javafx-maven-plugin but of the com.oracle.tools.packager.windows.WinExeBundler or WinAppBundler itself. There is somewhere a check if the bit-architecture of the executing JRE is the same as the JRE which should be embedded.

@aliebelt
Copy link
Author

Ok, I added following to my pom and it works! :) Both installers are created (64+32 bit):

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
        <execution>
            <goals>
                <goal>set-system-properties</goal>
            </goals>
            <configuration>
                <properties>
                    <property>
                        <name>fxpackager.disableBitArchitectureMismatchCheck</name>
                        <value>true</value>
                    </property>
                </properties>
            </configuration>
        </execution>
    </executions>
</plugin>

This is because of https://github.com/Debian/openjfx/blob/master/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java#L192

So: Either the bit-architecture check in WinAppBundler has to be improved or the javafx-maven-plugin should add this system property (maybe triggered by a plugin property).

@aliebelt
Copy link
Author

Unfortunately the created 32-bit installer (Inno Setup) produces a faulty installation:

It installs under C:\Programms not under C:\Programms (x86)
It is started as an 64-bit application (looked into Windows Task Manager)

When starting the applilcation it says: Failed to find library *\runtime\bin\client\jvm.dll then Failed to find library *\runtime\bin\msvcr100.dll then Failed to locate JNI_CreateJavaVM then Failed to launch JVM then the application is gone.

@aliebelt
Copy link
Author

This is not a problem of the two plugin executions. It's the same with an "old style" single execution configuration. You should be able to reproduce this problem by running the Maven build with a 64-bit JRE and have a 32-bit JRE declared in the plugin configuration.

@FibreFoX
Copy link
Member

Thanks a lot for the feedback, when having enough time (maybe next two days), i will look into this. Sounds very nice to have this feature!

@FibreFoX
Copy link
Member

FibreFoX commented May 3, 2015

I think I found something, could you retry with this configuration:

<executions>
    <execution>
        <id>create-installer-for-windows-64-bit</id>
        <configuration>
            <bundleArguments>
                <runtime>${jre-64-bit-path}</runtime>
            </bundleArguments>
        </configuration>
    </execution>
    <execution>
        <id>create-installer-for-windows-32-bit</id>
        <configuration>
            <bundleArguments>
                <runtime>${jre-32-bit-path}</runtime>
                <win.64Bit>x86</win.64Bit><!-- overwrite System.getProperty("os.arch") for bundler-detection -->
            </bundleArguments>
        </configuration>
    </execution>
</executions>

@aliebelt
Copy link
Author

aliebelt commented May 4, 2015

I tested it. The problem is the same as described above. An 32-bit installer is created without errors but the installer installs a not runnable application.

@FibreFoX
Copy link
Member

FibreFoX commented May 4, 2015

Could you create a sample project where I can recreate and check this scenario?

@aliebelt
Copy link
Author

aliebelt commented May 4, 2015

I created a sample maven project. Download the .png file and rename it to .zip -> The maven project is contained (I don't know how to upload zips to a github comment)
example-javafx-createinstallerwithcustomjre zip

You have to copy your 32bit JRE and 64bit JRE to a/the directories specified in the pom.
You should be sure to run maven with your 64 bit JRE (java -version) in console when running in console. Or you should check your run configuration in eclipse to run maven with a 64bit JRE.
Run with mvn clean install -> Both installers are created -> After installing the 32 bit installer the described error messages are displayed.

My versions:
JDK: 1.8.0_40-b25 64-Bit
Maven: 3.2.1

@aliebelt
Copy link
Author

aliebelt commented May 4, 2015

To get the error quicker, you can remove the "create-installer-for-windows-64-bit" execution. This will just execute the 32-bit installer creation (within a 64-bit runtime [Maven]).

@FibreFoX
Copy link
Member

FibreFoX commented May 4, 2015

Confirmed, I will work on this now.

@FibreFoX
Copy link
Member

FibreFoX commented May 4, 2015

I'm afraid, but this feature won't be possible, because the javapackager uses native files from within lib/ant-javafx.jar (inside installed JDK). See here:
https://github.com/Debian/openjfx/blob/master/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java#L347

I was possible to create a working native bundle, but I had to make some steps manually, which I don't want to create an utility-class/workaround for (because its no real solution):

<bundleArguments>
    <runtime>${jre-32-bit-path}</runtime>
    <win.64Bit>x86</win.64Bit>
    <win.launcher.rebrand>false</win.launcher.rebrand>
    <win.launcher.url>file:///some/path/to/resource/AS-URL/from/jdk/32bit/WinLauncher.exe</win.launcher.url>
</bundleArguments>

Then I extracted packager.dll, msvcp100.dll and msvcr100.dll into the app-folder.

The produced JRE will copied properly when having set <runtime> and <win.64Bit>, but the native files from lib/ant-javafx.jar are taken ... which does not correspond to 32bit when having 64bit-JDK, thats the reason your created bundle has working installer, but broken launcher-file.

Another hint: since it is possible to have java-version-mismatch for jdk/jre with modified runtime, more problems will arise: the packager changed since 1.8.0_25 by adding the DLL-files (see above), and having old JDK with configured newer JRE produces non-working bundles (because of missing DLL-files).

Therefor, the best solution for now is to run maven with 32 / 64-bit-JDK.

@FibreFoX FibreFoX closed this as completed May 4, 2015
@FibreFoX
Copy link
Member

FibreFoX commented May 4, 2015

Only solution is to have both versions of the JDK extracted/installed, and you have to override plugin-dependency with your custom path:

        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.1.3-SNAPSHOT</version>
            <dependencies>
                <dependency>
                    <groupId>javafx-packager</groupId>
                    <artifactId>javafx-packager</artifactId>
                    <version>1.8.0_20</version>
                    <scope>system</scope>
                    <!-- <systemPath>${jdk.32bit.home}/../lib/ant-javafx.jar</systemPath> -->
                    <systemPath>${jdk.64bit.home}/../lib/ant-javafx.jar</systemPath>
                </dependency>
            </dependencies>
        </plugin>

@aliebelt
Copy link
Author

aliebelt commented May 5, 2015

Ok, thanks for the investigation!

@aliebelt
Copy link
Author

aliebelt commented May 5, 2015

To sum it up in my words:

  • The bit architecture of the created installer depends on the bit architecture of the JRE which is used by Maven to run the build process (32bit installer only with 32bit JRE and 64bit installer only with 64bit JRE).
  • This problem is a deficit of the underlying JDK classes, libraries and executables for installer creation (NOT of the javafx-maven-plugin)

What can we do?

  1. File a BUG at JavaFX Jira (I will do it)
  2. Prevent the users of the javafx-maven-plugin to run in the same problem as me: E.g. Compare the running JVM bit architecture to the bit architecture of the selected (<bundleArguments><runtime>) JRE. And abort installer creation on mismatch.

What do you think?

@aliebelt
Copy link
Author

aliebelt commented May 5, 2015

https://javafx-jira.kenai.com/browse/RT-40718 [Native installers - provide a way to build a 32bit installer with 64bit JDK (and vice versa)]

@AugustKarlstedt
Copy link

@maxiwu
Copy link

maxiwu commented Aug 16, 2017

@what configuration could I use to generate an installer for 32 bit windows on my x64 machine?
I have installed the 32 bit jdk.

I am trying this configuration, result with skipping
Bit architecture mismatch between FX SDK and JRE runtime

<plugin>
				<groupId>com.zenjava</groupId>
				<artifactId>javafx-maven-plugin</artifactId>
				<version>8.8.3</version>
				<dependencies>
					<dependency>
						<groupId>javafx-packager</groupId>
						<artifactId>javafx-packager</artifactId>
						<version>1.8.0_144</version>
						<scope>system</scope>
						<!-- <systemPath>${jdk.32bit.home}/../lib/ant-javafx.jar</systemPath> -->
						<systemPath>C:\Program Files\Java\jdk1.8.0_144\lib\ant-javafx.jar</systemPath>
					</dependency>
				</dependencies>

<execution>
						<!-- required before build-native -->
						<id>create-jfxjar</id>
						<configuration>
							<bundleArguments>
								<runtime>C:\Program Files\Java\jdk1.8.0_144\jre</runtime>
							</bundleArguments>
						</configuration>

						<phase>package</phase>
						<goals>
							<goal>build-jar</goal>
						</goals>
					</execution>
					<execution>
						<id>create-native</id>
						<configuration>
							<bundleArguments>
								<runtime>C:\Program Files\Java\jdk1.8.0_144\jre</runtime>
								<win.64Bit>x86</win.64Bit>
							</bundleArguments>
						</configuration>
						<phase>package</phase>
						<goals>
							<goal>build-native</goal>
						</goals>
					</execution>
</plugin>

@FibreFoX
Copy link
Member

@maxiwu Currently there is no support, you will have to run maven with a different JDK set via JAVA_HOME on your 64bit machine. As discussed on the OpenJDK-bug, this is a jdk-problem with the bundling-system they are using. 32bit files/binaries are not contained inside 64bit installations (this is the mayor pain).

@maxiwu
Copy link

maxiwu commented Aug 18, 2017

@FibreFoX a workaround using maven in command line is good enough.
but I do not know how to configure javafx-maven-plugin to force it to use my 32 bit JDK.

I've changed my JAVA_HOME to a 32 bit Oracle JDK. And I run "mvn" package. With the right configuration, this should result in a 32 bit installer, if I am reading the discussion correctly.

I think the configuration which I am using above is not correct.
I've successfully create a 32bit installer once, but I didn't remember the correct configuration.
Or maybe I need to use the command "mvn clean jfx:native" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants