To bundle a Java Runtime Environment (JRE) with exe4j, you must use a relative search sequence. This ensures your final .exe file looks for Java inside its own directory rather than relying on a pre-installed system JRE.
Here is the step-by-step guide to achieving a completely self-contained Windows application. Step 1: Set Up Your Project Folder
Before opening exe4j, you must structure your application directory exactly how it will be distributed to your users. Create a root folder for your application (e.g., MyApp/). Place your compiled .jar file inside this folder.
Copy the entire jre folder from your local machine (usually found in C:\Program Files\Java</code>) and paste it inside your MyApp/ folder.
Note: For modern Java 9+, you can use jlink to generate a lightweight custom runtime folder instead of a bulky full JDK/JRE. Step 2: Configure the exe4j Wizard
Open exe4j and proceed through the initial project setup steps (Steps 1 to 3) to choose your directory, execution mode, and application name. Step 4: Executable Info
Set your Executable directory to a single dot (.) to target the root directory. Provide the name for your .exe. Step 5: Java Invocation
Leave a Reply