diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5d62751 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: weekly + day: wednesday + labels: [ ] diff --git a/.github/workflows/build-mwe-deb-icon.yml b/.github/workflows/build-mwe-deb-icon.yml new file mode 100644 index 0000000..c7f085f --- /dev/null +++ b/.github/workflows/build-mwe-deb-icon.yml @@ -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 diff --git a/.github/workflows/build-mwe-win.yml b/.github/workflows/build-mwe-win.yml new file mode 100644 index 0000000..43328d5 --- /dev/null +++ b/.github/workflows/build-mwe-win.yml @@ -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 diff --git a/.gitignore b/.gitignore index c7b85cb..974dffa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ *.class +*.deb *.jar *.iml *.exe *.msi *.log iamhomer/ + +FooClient/ +tmp/ diff --git a/.vscode/ltex.dictionary.en-US.txt b/.vscode/ltex.dictionary.en-US.txt new file mode 100644 index 0000000..19bb8c9 --- /dev/null +++ b/.vscode/ltex.dictionary.en-US.txt @@ -0,0 +1,2 @@ +jpackage +JabRef diff --git a/README.md b/README.md index ef41d3e..a2edb7a 100644 --- a/README.md +++ b/README.md @@ -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) +* +* +* +* [JabRef#15180](https://github.com/JabRef/jabref/issues/15180) - missing icon at JabRef diff --git a/build.jdk13.bat b/build.jdk13.bat deleted file mode 100644 index 6d39a13..0000000 --- a/build.jdk13.bat +++ /dev/null @@ -1,6 +0,0 @@ -SET JAVA_HOME=c:\Program Files\Java\jdk-13 -del *.class,*.jar,*.exe,*.msi - -"%JAVA_HOME%\bin\javac" FooClient.java -"%JAVA_HOME%\bin\jar" cfe fooclient.jar FooClient FooClient.class -"%JAVA_HOME%\bin\jpackage" create-installer --installer-type exe --input . --main-jar fooclient.jar --main-class FooClient --output . --verbose \ No newline at end of file diff --git a/build.jdk14.bat b/build.jdk14.bat deleted file mode 100644 index c703d2b..0000000 --- a/build.jdk14.bat +++ /dev/null @@ -1,6 +0,0 @@ -SET JAVA_HOME=c:\Program Files\Java\jdk-14 -del *.class,*.jar,*.exe,*.msi - -"%JAVA_HOME%\bin\javac" FooClient.java -"%JAVA_HOME%\bin\jar" cfe fooclient.jar FooClient FooClient.class -"%JAVA_HOME%\bin\jpackage" --package-type exe --input . --main-jar fooclient.jar --main-class FooClient --output . --verbose \ No newline at end of file diff --git a/build.jdk9.or.jdk10.bat b/build.jdk9.or.jdk10.bat deleted file mode 100644 index 0a44522..0000000 --- a/build.jdk9.or.jdk10.bat +++ /dev/null @@ -1,6 +0,0 @@ -SET JAVA_HOME=c:\Program Files\Java\jdk-10.0.2 -del *.class,*.jar,*.exe,*.msi - -"%JAVA_HOME%\bin\javac" FooClient.java -"%JAVA_HOME%\bin\jar" cfe fooclient.jar FooClient FooClient.class -"%JAVA_HOME%\bin\javapackager" -deploy -native installer -outdir . -srcdir . -srcfiles fooclient.jar -appclass FooClient -verbose \ No newline at end of file diff --git a/gg.cmd b/gg.cmd new file mode 100755 index 0000000..24168c8 Binary files /dev/null and b/gg.cmd differ diff --git a/FooClient.java b/mwe-deb-icon/FooClient.java similarity index 100% rename from FooClient.java rename to mwe-deb-icon/FooClient.java diff --git a/mwe-deb-icon/build.sh b/mwe-deb-icon/build.sh new file mode 100755 index 0000000..6222409 --- /dev/null +++ b/mwe-deb-icon/build.sh @@ -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 diff --git a/mwe-deb-icon/res/FooClient.png b/mwe-deb-icon/res/FooClient.png new file mode 100644 index 0000000..6aff117 Binary files /dev/null and b/mwe-deb-icon/res/FooClient.png differ diff --git a/mwe-deb-icon/res/two.png b/mwe-deb-icon/res/two.png new file mode 100644 index 0000000..ccfaf93 Binary files /dev/null and b/mwe-deb-icon/res/two.png differ diff --git a/mwe-win/FooClient.java b/mwe-win/FooClient.java new file mode 100644 index 0000000..cc8c3cb --- /dev/null +++ b/mwe-win/FooClient.java @@ -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); + }); + } +} diff --git a/mwe-win/JabRefTopBanner.bmp b/mwe-win/JabRefTopBanner.bmp new file mode 100644 index 0000000..7e95c3b Binary files /dev/null and b/mwe-win/JabRefTopBanner.bmp differ diff --git a/mwe-win/build.sh b/mwe-win/build.sh new file mode 100755 index 0000000..bb53c1b --- /dev/null +++ b/mwe-win/build.sh @@ -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 diff --git a/mwe-win/res/.gitkeep b/mwe-win/res/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mwe-win/res/main.wxs b/mwe-win/res/main.wxs new file mode 100644 index 0000000..052f9af --- /dev/null +++ b/mwe-win/res/main.wxs @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Not Installed + Not Installed + Not Installed + Not Installed + + Not Installed + + + Not Installed + + + Not Installed + + + + JP_UPGRADABLE_FOUND + + + JP_DOWNGRADABLE_FOUND + + + + + + + + + + + + diff --git a/mwe-win/res/override.wxi b/mwe-win/res/override.wxi new file mode 100644 index 0000000..c2faa85 --- /dev/null +++ b/mwe-win/res/override.wxi @@ -0,0 +1,31 @@ + + + + + diff --git a/opt-fooclient-lib.png b/opt-fooclient-lib.png new file mode 100644 index 0000000..587825c Binary files /dev/null and b/opt-fooclient-lib.png differ