Skip to content

EXE4j Jar to exe error

I’m recently Java 7 update 21 JDK and i created java application with netbeans For distributing my jar i use Exe4j 4.5.2 Jar to exe.

Now when i used Exe4j it creates exe but when i execute it it shows me error message.

“The JVM could not be started. The maximum heap size (-Xmx) might be too large or an antivirus or firewall tool could block the execution.”

After few test s i found out my previously(before installing JDK7u21) working application exe files from exe4j also now gives same error message.

(I’m Using 64 bit versions of JDK and EXE4j but complied exe is 32 bit.I want 32 bit application)

Answer

Exe4j works by loading the DLL of the target JVM, which requires the JVM to be of the same “bitness” with the executable wrapper. So a 32-bit Exe4j wrapper can only load a 32-bit JVM, while a 64-bit wrapper can only load a 64-bit JVM.

When Exe4j searches the registry for a JVM, it will ignore any JVM of the wrong bitness and look only through those of its own bitness. However, if you force Exe4j to load a specific JVM by setting the EXE4J_JAVA_HOME environment variable and the bitnesses don’t match, the loading of the JVM will fail.

If you want a 32-bit application (i.e. executable wrrapper), you must have a 32-bit JRE or JDK installed. If on the other hand you want a 64-bit JVM to be used, then you must provide a 64-bit executable wrapper.