An open API service indexing awesome lists of open source software.

https://github.com/hmasum52/java-custom-jre-tutorial

This project demonstrates how to make custom JRE to run a java project on any machine.
https://github.com/hmasum52/java-custom-jre-tutorial

custom-jre java-11 jdeps jlink module

Last synced: 9 months ago
JSON representation

This project demonstrates how to make custom JRE to run a java project on any machine.

Awesome Lists containing this project

README

          

### [Source code](https://github.com/Hmasum18/java-custom-jre-tutorial)

## Table of content
- [Compiling a Module](#compiling-a-module)
* [Compile and create class file in out folder](#compile-and-create-class-file-in-out-folder)
* [Compile and create class file in out folder](#compile-and-create-class-file-in-out-folder-1)
* [Run the class file from out folder](#run-the-class-file-from-out-folder)
+ [ouput](#ouput)
- [Using jdeps to List the Dependent Modules](#using-jdeps-to-list-the-dependent-modules)
+ [output](#output)
- [Creating a Custom JRE with jlink](#creating-a-custom-jre-with-jlink)
- [Run code with custom JRE](#run-code-with-custom-jre)
- [Creating Custom JRE with Launcher Scripts](#creating-custom-jre-with-launcher-scripts)

## Compiling a Module
### Compile and create class file in out folder
```bash
javac -d module-info.java

//example
javac -d out module-info.java
```

### Compile and create class file in out folder
```bash
javac -d --module-path

//example
javac -d out --module-path out github\hmasum18\jlinkTest\HelloWorld.java
```

### Run the class file from out folder
```bash
java --module-path --module /

//example
java --module-path out --module helloWorld/github.hmasum18.jlinkTest.HelloWorld
```
#### ouput
```
Mar 07, 2021 6:34:41 PM github.hmasum18.jlinkTest.HelloWorld main
INFO: hello world from masum
```

## Using jdeps to List the Dependent Modules
```bash
jdeps --module-path -s --module

//example
jdeps --module-path out -s --module helloWorld
```
#### output
```
helloWorld -> java.base
helloWorld -> java.logging
```

or
```bash
jdeps --list-deps --module-path -add-module

//example
jdeps --list-deps --module-path out --add-modules helloWorld

//example with javafx
jdeps --list-deps --module-path "lib\javafx-sdk-11.0.2\lib";"lib\gson-2.8.6.jar";"lib\jfoenix-9.0.10.jar";"out\production\CarShowRoomFrontend" --add-modules fontend
```

## Creating a Custom JRE with jlink
```bash
jdeps --module-path --add-modules --output

//example
jlink --module-path "%JAVA_HOME%\jmods";out --add-modules helloWorld --output customjrefolder
```

## Run code with custom JRE

```bash
"\java" --module-path -m

//example
"customjrefolder\bin\java" --module-path out -m helloWorld/github.hmasum18.jlinkTest.HelloWorld
```

## Creating Custom JRE with Launcher Scripts
```bash
jlink --launcher helloWorldLauncher=helloWorld/github.hmasum18.jlinkTest/HelloWorld --module-path "%JAVA_HOME%\jmods";out --add-modules helloWorld --output customJreLauncherFolder
```