Generated Exe Configuration

Generated exe file is configurable for extra options


Overview

After an exe file has been generated, it is configurable for extra options, such as Java vm parameters, or options defined by Jar2Exe. Generated exe file is configured through a Configuration File, which is a text file in the same directory as generated exe file.


Internal Config & External Config

The configurations can be internal in the exe file [since 2.0.3], or outside in a configuration file, or both. The configuration file outside is a text file in the same directory as generated exe file, with the same filename plus a extension name ".cfg" or ".config".

 You can click "Config Internal" at Step 6: Output to make configurations inside the exe file, or click "Config External" at Step 7: Finish to make a configuration file outside, or both.

If the exe file has been generated, you can start 'Config Assistant' from Start Menu and select the exe file you want to configure. Config Assistat will load the current configuration if exists, and it will help you to save the configuration file.


Configuration File Content

The configuration file is a text file, each line is a configure item. The format of configure item is "keyword value". If a line is not started with a known keyword, this line is ignored.


Refer to Environment Variable by %VARNAME% or $VARNAME

In the configuration file, you can use a placeholder to refer to environments. Generated exe supports Linux style placeholder $PATH and Windows style placeholder %PATH%. For example:

option -Dpath.string=$PATH

is to define a System Property "path.string", the property value is the environment variable PATH.

There are serveral internal placeholder, which is not from environments:

  • $APPLICATION_HOME - The directory where the generated exe file is.
  • $J2E_APP_PATH - The full path of generated exe file.
  • $PWD - The current working directory.

If you want to express '$' character itself, not to be regarded as a placeholder, use '$$' to stand for '$' character, '%%' to stand for '%' character.


Refer to Windows Registry by ${REGISTRY_PATH\Item}

This is for Windows only, since Jar2Exe V2.1.3. In configure file, you can refer to Windows Registry by a placeholder. The syntax is:

${REGISTRY_PATH\Item|default}

If the "REGISTRY_PATH" not found or "Item" not found, the "default" value will be returned. To get the "(Default)" item, leave "Item" empty like ${REGISTRY_PATH\|default}. The "|default" can be omited, if there is no "|default", the whole placeholder will not be translated if the REGISTRY_PATH or Item not found.


jre_order

'jre_order' is to configure the JRE Find Order. The default order is "cbsie", each letter stands for a search way:

  • c - Configured JRE by 'jvmdll'
  • b - Bundled JRE path by 'jre' item
  • s - Installed SUN JRE (Windows) / or 'java' symbol link (Linux)
  • i - Installed IBM JRE (Windows)
  • e - Environment JAVA_HOME or JRE_HOME

If jre_order exists in configuration file, generated exe will find JRE in the order specified.

  • See jre_order page for detais JRE find order.

jvmdll

In configuration file, 'jvmdll' is used to specify a JRE, through an absolute path or relative path to "jvm.dll" on Windows, "libjvm.so" on Linux.

  • See jvmdll page for details of specifying a JRE by path.

jre [since 2.0.3]

In configuration file, 'jre' is used to specify a JRE like 'jvmdll', through an absolute path or relative path to "jre" directory or "jdk" directory.

  • See jre page for details of specifying a JRE by path.

vm

Configure item 'vm' is to specify a preferred vm, "server" or "client". Generated exe will try to select the preferred VM first, except the JRE is specified by 'jvmdll'.

  • See vm page for selecting a preferred vm.

minjre

Jar2Exe supports to set a minimum java.version for generated exe, such as 1.2, 1.3 etc.

In configuration file, you can use 'minjre' to set a new value to overwrite the value during generating. As you need, you can set a more precise value, e.g. "1.6.0_10"

  • See minjre page for details of minimum java.version configuration.

option

The 'option' item is used to set java vm parameters defined by JRE. For example: "option -Xmx1024m", "option -Dhello.string=Hello" etc.

  • See option page for details of defining java vm parameters.

property

The 'property' item is used to define a System Property, it is equalent to "option -D".

  • See property page for details of defining System Property.

forcecwd

The 'forcecwd' item is to set the current working directory with a relative path from generated exe, or an absolute path.

  • See forcecwd page for details of setting current working directory.

classpath, libs

The 'classpath' item is to add jar files to java classpath. The 'libs' item points to a directory, in which all jar files will be added to java classpath.


export

To define a environment variable which can be referred by other configure item through placeholder, or can be gotten by System.getenv() within java code.

  • See export page for details of defining a environment variable.

stdout, stderr

To set a file or pipe for System.out and System.err to be redirected to.

Comments

Error with AdoptOpenJDK 11

Hello,

We have a problem with Jar2exe version 2.5 and AdoptOpenJDK version 11. We have a GUI application and a service application, both compiled with "jre_order bcesi".

Our GUI application encounters an exception when using a bundled JRE (in "jre" subdirectory) and is trying to read fonts. The fonts and application are in the same jar. If we put the JRE in different directory and use configuration file and jvmdll parameter, the program works (but the service application does not work, read below). With jar2exe version 2.2 and JRE 1.8 the bundled JRE worked. Here's the stacktrace:

210114:064633.808 Error loading resource font:/com/xxxxx/resources/fonts/RobotoMono-Regular.ttf
*** BEGIN EXCEPTION (java.io.IOException: Problem reading font data.) ***
java.io.IOException: Problem reading font data.
at java.desktop/java.awt.Font.createFont0(Font.java:1183)
at java.desktop/java.awt.Font.createFont(Font.java:1052)

...

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at com.regexlab.j2e.Jar2ExeLauncher.main(Jar2ExeLauncher.java:48)
*** END EXCEPTION ***

Our service application only works with bundled JRE, but not with jvmdll parameter.

OpenJDK 11 bundled problem

Hello,

We have converted our jar (compiled with adaptopenjdk 11) to exe with configuration option "jre_order bcesi", but if we put the JRE under subdirectory "jre" the exe will not start. Only if we change the subdirectory name to e.g. "jre_" and make on configuration file with line "jvmdll .\jre_\bin\client\jvm.dll", the executable will start. Can you check this and make a fix, if you can reproduce the problem?

Override arguments passed to jar

I am evaluating using jar2exe to package a client application. I would like to specify the command line parameters to be passed to javaw, rather than passing through the arguments to the exe. Is there any way to do this?

Could not find or load main class

Hello, when I run java -jar myjar.jar it work.

But whem I use JarTo Exe I got : Could not find or load main class

 

any help?

 

thanks

JVM Config

Hi, 

 

I purchased your Product, I have problem adding JVM parmeters while making .exe

These are following paramters needs to add to JVM

-Dcom.sun.javafx.isEmbedded=true
-Dcom.sun.javafx.virtualKeyboard=javafx
-Dcom.sun.javafx.touch=true

Please help me to resolve this issue.

Thanks

Veerendra Jetty

UI Scale using JFXPanel

Dear Ladies and Gentlemen,

I use Swing and would like to use the FileChooser by javafx.

My application I start as exe converted with Jar2Exe. The surface is scaled correctly according to the setting under Windows 10 for example 150%.

The use of FileChooser requires the initialization of a JFXPanel. The call immediately resets the scaling without errors. However, the display is now much too small for high-resolution displays.

The scaling is done already when I the command
Code:
PlatformImpl.startup (() -> {})
;. This is important for the initialization of the toolkit from javafx.

The problem happens exactly
Code:
com.sun.javafx.tk.Toolkit.getToolkit (). Startup (() -> {});
This is however native.

Is there a property, a flag, or other to reset or ignore.

I hope someone can help me I've already researched a lot on the Internet.

Can your program run normally without Jar2Exe?

Are you asking a question about JFXPanel or about Jar2Exe ?

If your program can run normally as you wish without Jar2Exe, but failed after converted into an exe, then your problem is about Jar2Exe. Then I could trace into the problem.

Add new comment