{"id":18429472,"url":"https://github.com/jgneff/hello-java","last_synced_at":"2026-01-31T15:01:46.902Z","repository":{"id":57831073,"uuid":"314366340","full_name":"jgneff/hello-java","owner":"jgneff","description":"Project template for creating and deploying Java apps","archived":false,"fork":false,"pushed_at":"2024-06-08T18:47:55.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T07:05:00.487Z","etag":null,"topics":["java","linux","snap","swing"],"latest_commit_sha":null,"homepage":"https://snapcraft.io/hello-java","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jgneff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jgneff"}},"created_at":"2020-11-19T20:46:54.000Z","updated_at":"2024-06-08T18:47:59.000Z","dependencies_parsed_at":"2025-04-07T17:48:38.209Z","dependency_job_id":null,"html_url":"https://github.com/jgneff/hello-java","commit_stats":null,"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/jgneff/hello-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgneff%2Fhello-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgneff%2Fhello-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgneff%2Fhello-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgneff%2Fhello-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgneff","download_url":"https://codeload.github.com/jgneff/hello-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgneff%2Fhello-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28946055,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","linux","snap","swing"],"created_at":"2024-11-06T05:17:20.020Z","updated_at":"2026-01-31T15:01:46.886Z","avatar_url":"https://github.com/jgneff.png","language":"Makefile","funding_links":["https://github.com/sponsors/jgneff"],"categories":[],"sub_categories":[],"readme":"# ![Duke, the Java mascot, waving](images/icon.png) Hello Java!\n\nThis project is my template for building and packaging Java applications. It follows the conventions of Apache Maven for its directory structure and includes two sample applications that print \"Hello World!\" to standard output:\n\n* HelloWorld - a Java console application with a command-line interface\n* HelloSwing - a Java Swing application with a graphical user interface\n\nThe files in this project let you:\n\n* open the project in an integrated development environment (IDE),\n* create an executable Java archive (JAR) of each application,\n* package the API documentation and source code as JAR files, and\n* test and run the applications.\n\nIn addition to the standard JAR artifacts, you can also create packages for Linux that include a custom run-time image. The table below shows the package size and installed size for each type of package. The Snap package remains the same size when installed because the package file is mounted as a compressed read-only file system instead of being extracted like the others.\n\n| Type    | Package (MB) | Installed (MB) |\n| ------- |:------------:|:--------------:|\n| Archive | 25           | 75             |\n| Debian  | 18           | 84             |\n| Snap    | 25           | 25             |\n\nFurthermore, on Debian-based distributions like Ubuntu, you can build all of these artifacts locally using only the trusted software from your system's package repositories.\n\n## Building\n\nThis project supports the following build automation tools:\n\n* [Apache Maven](https://maven.apache.org) - runs *online* with Maven Central or *offline* with a local Debian repo\n* [GNU Make](https://www.gnu.org/software/make/) - requires only the Java Development Kit (JDK)\n* [Snapcraft](https://snapcraft.io/build) - builds a self-contained application for any Linux distribution\n\nThe `package` phase of Maven creates the following JAR files, where *x.y.z* is the version string:\n\n* Module org.status6.hello.world\n    * target/hello-world-*x.y.z*.jar - Java application\n    * target/hello-world-*x.y.z*-javadoc.jar - API documentation\n    * target/hello-world-*x.y.z*-sources.jar - Source code\n* Module org.status6.hello.swing\n    * target/hello-swing-*x.y.z*.jar - Java application\n    * target/hello-swing-*x.y.z*-javadoc.jar - API documentation\n    * target/hello-swing-*x.y.z*-sources.jar - Source code\n\nThe `package` target of the Makefile creates the same JAR files in the `dist` directory. The `linux` target, along with the `install` target run by Snapcraft, builds the following Linux packages:\n\n* dist/hello-java-*x.y.z*-linux-amd64.tar.gz - Compressed archive\n* dist/hello-java_*x.y.z*-1_amd64.deb - Debian package\n* hello-java_*x.y.z*_amd64.snap - Snap package\n\nMaven can run on any system, but the Makefile is configured by default for Ubuntu. Whether you're running Windows, macOS, or Linux, you can use [Multipass](https://multipass.run) to build the project in an Ubuntu virtual machine (VM). For example, the following command will launch the Multipass [primary instance](https://multipass.run/docs/primary-instance) with 2 processors, 4 GiB of RAM, and Ubuntu 20.04 LTS (Focal Fossa):\n\n```console\n$ multipass launch --name primary --cpus 2 --mem 4G focal\n```\n\nRun the build commands from the directory where you cloned this repository:\n\n```console\n$ git clone https://github.com/jgneff/hello-java.git\n$ cd hello-java\n$ mvn clean package\n```\n\n### Apache Maven\n\nThe Maven [Project Object Model](pom.xml) lets you build the project with an IDE or from the command line with:\n\n```console\n$ sudo apt install maven\n$ export JAVA_HOME=/usr/lib/jvm/default-java\n$ mvn clean package\n```\n\n**Note:** Maven 3.6.3-1 in Ubuntu 20.04 LTS [fails to run with OpenJDK 16](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980467). The error is fixed in Maven package version 3.6.3-2. To work around the problem, either run Maven with the Ubuntu default of OpenJDK 11, as shown above, or download the [latest version of Maven](https://maven.apache.org/download.cgi) directly from Apache.\n\nBy default, the `mvn` command runs the build in *online* mode and downloads the required plugins and dependencies from the Maven Central Repository. On Debian-based systems such as Ubuntu, you can run the build in *offline* mode using the local repository of plugins and dependencies built by your Linux distribution.\n\nTo run the build locally, install the Maven Debian Helper and the Maven plugins for creating the Javadoc and source archives:\n\n```console\n$ sudo apt install maven-debian-helper\n$ sudo apt install libmaven-javadoc-plugin-java\n$ sudo apt install libmaven-source-plugin-java\n```\n\nWith those packages installed, you can build offline using only the local Debian repository:\n\n```console\n$ mvn -s /etc/maven/settings-debian.xml -P debian clean package\n```\n\nCombine the Debian settings and the `debian` profile activation by creating the file `~/.m2/debian.xml` with the following content:\n\n```XML\n\u003csettings\u003e\n    \u003c!-- Switches Maven to offline mode and uses the local Debian repo --\u003e\n    \u003clocalRepository\u003e/usr/share/maven-repo\u003c/localRepository\u003e\n    \u003coffline\u003etrue\u003c/offline\u003e\n    \u003cactiveProfiles\u003e\n        \u003cactiveProfile\u003edebian\u003c/activeProfile\u003e\n    \u003c/activeProfiles\u003e\n\u003c/settings\u003e\n```\n\nCreate a Bash alias in `~/.bash_aliases` that uses the `debian.xml` Maven settings:\n\n```bash\nalias dmvn='mvn -s ~/.m2/debian.xml'\n```\n\nThen you can run `mvn` for online mode using the Maven Central repository and `dmvn` for offline mode using the local Debian repository.\n\n### GNU Make\n\nThe [Makefile](Makefile) builds the same JAR files as Maven, but it does so using only the tools that come with the Java Development Kit. You can install GNU Make and OpenJDK 16 on Debian-based distributions with the commands:\n\n```console\n$ sudo apt install make openjdk-16-jdk\n```\n\nTo run all of the Makefile targets, you'll also need the JUnit testing framework and two extra packages for building the compressed archive and Debian package:\n\n```console\n$ sudo apt install junit4 binutils fakeroot\n```\n\nRun `make` with the targets shown below to build the JAR files into the `dist` directory and run the unit test cases:\n\n```console\n$ make clean package test\n```\n\nThe `run` target runs each application from its executable JAR file:\n\n```console\n$ make run\n```\n\nThe Makefile can also package the project as a self-contained application in the following formats:\n\n* compressed archive for extracting to any location,\n* Debian package for installing into `/opt` on Debian-based systems, and\n* Snap package for uploading to the [Snap Store](https://snapcraft.io/store).\n\nThe `linux` target builds the compressed archive and Debian package for Linux:\n\n```console\n$ make linux\n```\n\n### Snapcraft\n\nThe [snapcraft.yaml](snap/snapcraft.yaml) file defines the build for Snapcraft. Run the following commands to install Snapcraft, change to the repository directory, and build the Snap package:\n\n```console\n$ sudo snap install snapcraft\n$ cd hello-java\n$ make clean\n$ snapcraft\n```\n\nSnapcraft launches a new Multipass VM to ensure a clean and isolated build environment. The VM is named `snapcraft-hello-java` and runs Ubuntu 20.04 LTS (Focal Fossa). The project's directory on the host system is mounted as `/root/project` in the guest VM, so any changes you make on the host are seen immediately in the guest, and vice versa.\n\n**Note:** If you run the initial `snapcraft` command itself inside a VM, your system will need *nested VM* functionality. See the [Build Options](https://snapcraft.io/docs/build-options) page for alternatives, such as running a remote build or using an LXD container.\n\nIf the build fails, you can run the command again with the `--debug` option to remain in the VM after the error:\n\n```console\n$ snapcraft -d\n```\n\nFrom within the VM, you can then clean the Snapcraft part and try again:\n\n```console\n# snapcraft clean app\nCleaning pull step (and all subsequent steps) for app\n# snapcraft\n```\n\nThe Snapcraft [*make* plugin](https://snapcraft.io/docs/make-plugin) uses the same [Makefile](Makefile) as before, but it runs GNU Make in the guest VM. The plugin runs the commands `make` and `make install`, as shown below:\n\n```console\n# snapcraft\n  ...\nBuilding app\n+ snapcraftctl build\n+ make -j4\n  ...\n+ make -j4 install DESTDIR=/root/parts/app/install\n  ...\nSnapping...\nSnapped hello-java_1.0.0_amd64.snap\n```\n\nWhen the build completes, you'll find the Snap package in the project's root directory, along with the build log file if you ran the build remotely.\n\n## Running\n\nAfter building the executable JAR files and installing the Linux packages, you can run the applications in all of the following ways:\n\n1. as a class file,\n2. as the main class in a JAR file,\n3. as the main class in a module,\n4. as a single source-file program,\n5. from the compressed archive extracted into `~/opt`,\n6. from the installed Debian package, and\n7. from the installed Snap package.\n\nEach of these methods is shown below for the two applications.\n\n### HelloWorld\n\nThe HelloWorld application prints \"Hello World!\" to standard output.\n\n```console\n$ java -cp dist/hello-world-1.0.0.jar org.status6.hello.world.Hello\nHello World!\n$ java -jar dist/hello-world-1.0.0.jar\nHello World!\n$ java -p dist/hello-world-1.0.0.jar -m org.status6.hello.world\nHello World!\n$ java org.status6.hello.world/src/main/java/org/status6/hello/world/Hello.java\nHello World!\n$ ~/opt/hello-java/bin/HelloWorld\nHello World!\n$ /opt/hello-java/bin/HelloWorld\nHello World!\n$ hello-java.console\nHello World!\n```\n\n### HelloSwing\n\nThe HelloSwing application prints \"Hello World!\" to standard output when its button is pressed.\n\n```console\n$ java -cp dist/hello-swing-1.0.0.jar org.status6.hello.swing.Hello\nHello World!\n$ java -jar dist/hello-swing-1.0.0.jar\nHello World!\n$ java -p dist/hello-swing-1.0.0.jar -m org.status6.hello.swing\nHello World!\n$ java org.status6.hello.swing/src/main/java/org/status6/hello/swing/Hello.java\nHello World!\n$ ~/opt/hello-java/bin/HelloSwing\nHello World!\n$ /opt/hello-java/bin/HelloSwing\nHello World!\n$ hello-java\nHello World!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgneff%2Fhello-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgneff%2Fhello-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgneff%2Fhello-java/lists"}