Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
day: wednesday
labels: [ ]
49 changes: 49 additions & 0 deletions .github/workflows/build-mwe-deb-icon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: MWE deb icon

on:
pull_request:
branches: [master, upate-to-jdk25]
push:
branches: [master]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm] # TODO: macos-latest, windows-latest
# 17 and 21 do not work with the current setup
jdkversion: [24, 25, GA, EA]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v6

- uses: koppor/gg/action@af034fd18934f51f117a1bb72102c5cbd04a96e0
if: matrix.jdkversion != 'GA' && matrix.jdkversion != 'EA'
- name: Build (JDK ${{ matrix.jdkversion }})
if: matrix.jdkversion != 'GA' && matrix.jdkversion != 'EA'
shell: bash
run: |
cd mwe-deb-icon
gg.cmd run:java@${{ matrix.jdkversion }} bash ./build.sh

- name: 'Set up latest JDK ${{ matrix.jdkversion }} from jdk.java.net'
if: matrix.jdkversion == 'GA' || matrix.jdkversion == 'EA'
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ matrix.jdkversion }}
- name: Build (JDK ${{ matrix.jdkversion }})
if: matrix.jdkversion == 'GA' || matrix.jdkversion == 'EA'
shell: bash
run: |
cd mwe-deb-icon
./build.sh

- name: Upload FooClient
uses: actions/upload-artifact@v4
with:
name: mwe-deb-icon-jdk-${{ matrix.jdkversion }}-${{ matrix.os }}
path: "mwe-deb-icon/*.deb"
if-no-files-found: error
51 changes: 51 additions & 0 deletions .github/workflows/build-mwe-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: MWE win

on:
pull_request:
branches: [master, upate-to-jdk25]
push:
branches: [master]

jobs:
build:
strategy:
matrix:
os: [windows-latest] # TODO: macos-latest, ubuntu-latest, ubuntu-24.04-arm
# 17 and 21 do not work with the current setup
jdkversion: [24, 25, GA, EA]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v6

- uses: koppor/gg/action@af034fd18934f51f117a1bb72102c5cbd04a96e0
if: matrix.jdkversion != 'GA' && matrix.jdkversion != 'EA'
- name: Build (JDK ${{ matrix.jdkversion }})
if: matrix.jdkversion != 'GA' && matrix.jdkversion != 'EA'
shell: bash
run: |
cd mwe-win
gg.cmd run:java@${{ matrix.jdkversion }} bash ./build.sh

- name: 'Set up latest JDK ${{ matrix.jdkversion }} from jdk.java.net'
if: matrix.jdkversion == 'GA' || matrix.jdkversion == 'EA'
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ matrix.jdkversion }}
- name: Build (JDK ${{ matrix.jdkversion }})
if: matrix.jdkversion == 'GA' || matrix.jdkversion == 'EA'
shell: bash
run: |
cd mwe-win
./build.sh

- name: Upload FooClient
uses: actions/upload-artifact@v4
with:
name: mwe-win-jdk-${{ matrix.jdkversion }}-${{ matrix.os }}
path: |
mwe-win/*.msi
mwe-win/tmp
if-no-files-found: warn
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
*.class
*.deb
*.jar
*.iml
*.exe
*.msi
*.log
iamhomer/

FooClient/
tmp/
2 changes: 2 additions & 0 deletions .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jpackage
JabRef
59 changes: 44 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
### Java Minimum Desktop App
# Java Minimum Desktop App Examples

To demonstrate how easy is to build a desktop application with Java.

##### Prerequisites for development
Demonstrates JDK24 and JDK25 for creating a `.deb` package and an `.msi` installer.

* Windows 10 x64/
* Oracle JDK 10.0.2 (http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html)
* Oracle JDK 13-jpackage+36 (https://jdk.java.net/jpackage/)
* Oracle JDK 14-jpackage+35 (https://jdk.java.net/jpackage/)
* Inno Setup 5.6.1 (u) (http://www.jrsoftware.org/isdl.php)
## Included MWEs

##### Hints
### `mwe-deb-icon`

This app has two icons:

* [res/FooClient.png](./res/FooClient.png) - png with one as number
* [res/two.png](./res/two.png) - png with two as number

`deb` should use `two.png`, but uses 1:

![/opt/fooclient/lib showing one instead of two](opt-fooclient-lib.png)

Note: On JDK24, the correct icon is used.

[JDK-8356048](https://bugs.openjdk.org/browse/JDK-8356048)

### `mwe-win`

Will be expanded to show [JDK-8278383](https://bugs.openjdk.org/browse/JDK-8278383).

## Hints

For a smooth building experience, it is recommended that you follow these rules on where and how to check out the source code.

* Do not check out the source code in a path which contains spaces or special characters. Chances are the build will not work. This is most likely to be an issue on Windows systems.
* Do not check out the source code in a path which has a very long name or is nested many levels deep. Chances are you will hit an OS limitation during the build.

##### How to build
## How to build

You can quickly try out with [`gg.cmd`](https://github.com/eirikb/gg):

```bash
cd mwe-deb-icon
../gg.cmd run:java@25 bash ./build.sh
```

Replace `25` with the JDK version you want to try.

See .bat files.
For manual steps, see respective `build.sh`.

The javapackager will create the installer exe for this self-contained application. It consists of a single, installable bundle that contains the application and a copy of the JRE needed to run the application. When the application is installed, it behaves the in the same way as any native application.
`jpacakge` will create the installer `deb` for this self-contained application. It consists of a single, installable bundle that contains the application and a copy of the JRE needed to run the application. When the application is installed, it behaves the in the same way as any native application.

##### More to read
## More to read

* https://docs.oracle.com/javase/tutorial/deployment/selfContainedApps/index.html
* https://docs.oracle.com/javase/10/tools/javapackager.htm#JSWOR719
* https://andrastornai.com/
* [jpackage](https://docs.oracle.com/en/java/javase/25/docs/specs/man/jpackage.html)
* [override jpackage resources](https://docs.oracle.com/en/java/javase/25/jpackage/override-jpackage-resources.html)
* [`template.desktop`](https://github.com/openjdk/jdk/blob/a35945ae067ffd60d5f374060086650636ebd9de/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.desktop)
* <https://docs.oracle.com/javase/tutorial/deployment/selfContainedApps/index.html>
* <https://docs.oracle.com/javase/10/tools/javapackager.htm#JSWOR719>
* <https://andrastornai.com/>
* [JabRef#15180](https://github.com/JabRef/jabref/issues/15180) - missing icon at JabRef
6 changes: 0 additions & 6 deletions build.jdk13.bat

This file was deleted.

6 changes: 0 additions & 6 deletions build.jdk14.bat

This file was deleted.

6 changes: 0 additions & 6 deletions build.jdk9.or.jdk10.bat

This file was deleted.

Binary file added gg.cmd
Binary file not shown.
File renamed without changes.
11 changes: 11 additions & 0 deletions mwe-deb-icon/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -ex

# Remove build directory
rm -rf FooClient/
rm -rf tmp/
mkdir tmp

"$JAVA_HOME/bin/javac" FooClient.java
"$JAVA_HOME/bin/jar" cfe fooclient.jar FooClient FooClient.class
"$JAVA_HOME/bin/jpackage" --type app-image --input . --main-jar fooclient.jar --main-class FooClient --verbose --temp tmp/ --resource-dir res/ --icon res/FooClient.png
"$JAVA_HOME/bin/jpackage" --type deb --app-image FooClient/ --verbose --temp tmp/ --icon res/two.png
Binary file added mwe-deb-icon/res/FooClient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mwe-deb-icon/res/two.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions mwe-win/FooClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import javax.swing.*;

public class FooClient {

public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("HelloWorld");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(320, 200);
frame.toFront();
frame.setVisible(true);
});
}
}
Binary file added mwe-win/JabRefTopBanner.bmp
Binary file not shown.
14 changes: 14 additions & 0 deletions mwe-win/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set -ex

# Remove build directory
rm -rf FooClient/
rm -rf tmp/
mkdir tmp

JAVA_HOME="${JAVA_HOME//\\//}"

"$JAVA_HOME/bin/javac" FooClient.java
"$JAVA_HOME/bin/jar" cfe fooclient.jar FooClient FooClient.class
"$JAVA_HOME/bin/jpackage" --type app-image --input . --main-jar fooclient.jar --main-class FooClient --verbose --resource-dir res/
"$JAVA_HOME/bin/jpackage" --type msi --app-image FooClient/ --verbose --resource-dir res/ --temp tmp
cd tmp && ls -l
Empty file added mwe-win/res/.gitkeep
Empty file.
Loading
Loading