Using ActiveRecord with SQLite DB in a JRuby Desktop App

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • glimmer-dsl-swt

    Glimmer DSL for SWT (JRuby Desktop Development Cross-Platform Native GUI Framework) - The Quickest Way From Zero To GUI - If You Liked Shoes, You'll Love Glimmer!

  • SQLite is the simplest relational database to use from JRuby desktop applications, it is built-in on all platforms (Mac, Windows, and Linux), and it can be utilized conveniently via ActiveRecord, the Rails object-relational mapping library following the Active Record Enterprise Application Architecture Pattern. In fact, I have used it a few years ago to build Are We There Yet?, a small project management app, using Glimmer DSL for SWT and bidirectional data-binding. In this blog post tutorial, I cover how to configure a SQLite database and connect to it using ActiveRecord from within a Ruby desktop application, data-binding the ActiveRecord Model to the GUI View bidirectionally.

  • contact_manager

    Contact Manager is a Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) sample leveraging SQLite DB via ActiveRecord.

  • Let us build a simple Contact Manager desktop app to demonstrate how to use a relational database to store contacts in a SQLite database via ActiveRecord.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • rubygems

    Library packaging and distribution for Ruby.

  • % glimmer "scaffold[contact_manager]" Fetching highline-2.0.3.gem Fetching rack-2.2.3.gem Fetching semver2-3.4.2.gem Fetching kamelcase-0.0.2.gem Fetching nokogiri-1.13.4-java.gem Fetching multi_xml-0.6.0.gem Fetching multi_json-1.15.0.gem Fetching jwt-2.3.0.gem Fetching ruby2_keywords-0.0.5.gem Fetching faraday-retry-1.0.3.gem Fetching faraday-rack-1.0.0.gem Fetching faraday-patron-1.0.0.gem Fetching faraday-net_http-1.0.1.gem Fetching faraday-net_http_persistent-1.2.0.gem Fetching multipart-post-2.1.1.gem Fetching faraday-multipart-1.0.3.gem Fetching faraday-httpclient-1.0.1.gem Fetching faraday-excon-1.1.0.gem Fetching faraday-em_synchrony-1.0.0.gem Fetching faraday-em_http-1.0.0.gem Fetching hashie-3.6.0.gem Fetching thread_safe-0.3.6-java.gem Fetching descendants_tracker-0.0.4.gem Fetching public_suffix-4.0.6.gem Fetching addressable-2.8.0.gem Fetching github_api-0.19.0.gem Fetching faraday-1.10.0.gem Fetching oauth2-1.4.9.gem Fetching rchardet-1.8.0.gem Fetching git-1.10.2.gem Fetching builder-3.2.4.gem Fetching juwelier-2.4.9.gem Successfully installed semver2-3.4.2 Successfully installed nokogiri-1.13.4-java Successfully installed kamelcase-0.0.2 Successfully installed highline-2.0.3 Successfully installed rack-2.2.3 Successfully installed multi_xml-0.6.0 Successfully installed multi_json-1.15.0 Successfully installed jwt-2.3.0 Successfully installed ruby2_keywords-0.0.5 Successfully installed faraday-retry-1.0.3 Successfully installed faraday-rack-1.0.0 Successfully installed faraday-patron-1.0.0 Successfully installed faraday-net_http_persistent-1.2.0 Successfully installed faraday-net_http-1.0.1 Successfully installed multipart-post-2.1.1 Successfully installed faraday-multipart-1.0.3 Successfully installed faraday-httpclient-1.0.1 Successfully installed faraday-excon-1.1.0 Successfully installed faraday-em_synchrony-1.0.0 Successfully installed faraday-em_http-1.0.0 Successfully installed faraday-1.10.0 Successfully installed oauth2-1.4.9 Successfully installed hashie-3.6.0 Successfully installed thread_safe-0.3.6-java Successfully installed descendants_tracker-0.0.4 Successfully installed public_suffix-4.0.6 Successfully installed addressable-2.8.0 Successfully installed github_api-0.19.0 Successfully installed rchardet-1.8.0 Successfully installed git-1.10.2 Successfully installed builder-3.2.4 Successfully installed juwelier-2.4.9 32 gems installed irb_chwscreate.gitignore irb_chwscreateRakefile irb_chwscreateGemfile irb_chwscreateLICENSE.txt irb_chwscreateREADME.markdown irb_chwscreate.document irb_chwscreatelib irb_chwscreatelib/contact_manager.rb irb_chwscreate.rspec Juwelier has prepared your gem in ./contact_manager Created contact_manager/.gitignore Created contact_manager/.ruby-version Created contact_manager/.ruby-gemset Created contact_manager/VERSION Created contact_manager/LICENSE.txt Created contact_manager/Gemfile Created contact_manager/Rakefile Created contact_manager/app/contact_manager.rb Created contact_manager/app/contact_manager/view/app_view.rb Created contact_manager/icons/windows/Contact Manager.ico Created contact_manager/icons/macosx/Contact Manager.icns Created contact_manager/icons/linux/Contact Manager.png Created contact_manager/app/contact_manager/launch.rb Created contact_manager/bin/contact_manager jruby-9.3.4.0 - #gemset created /Users/andymaleh/.rvm/gems/jruby-9.3.4.0@contact_manager jruby-9.3.4.0 - #generating contact_manager wrappers.............. Fetching gem metadata from https://rubygems.org/......... Resolving dependencies................... Using rake 13.0.6 Fetching public_suffix 4.0.6 Fetching array_include_methods 1.4.0 Fetching awesome_print 1.9.2 Fetching builder 3.2.4 Installing builder 3.2.4 Installing array_include_methods 1.4.0 Installing awesome_print 1.9.2 Installing public_suffix 4.0.6 Using bundler 2.3.9 Fetching concurrent-ruby 1.1.10 Fetching thread_safe 0.3.6 (java) Installing concurrent-ruby 1.1.10 Fetching diff-lcs 1.5.0 Installing thread_safe 0.3.6 (java) Installing diff-lcs 1.5.0 Fetching docile 1.4.0 Installing docile 1.4.0 Fetching facets 3.1.0 Fetching faraday-em_http 1.0.0 Fetching faraday-em_synchrony 1.0.0 Installing faraday-em_http 1.0.0 Installing facets 3.1.0 Installing faraday-em_synchrony 1.0.0 Fetching faraday-excon 1.1.0 Fetching faraday-httpclient 1.0.1 Installing faraday-excon 1.1.0 Installing faraday-httpclient 1.0.1 Fetching multipart-post 2.1.1 Fetching faraday-net_http 1.0.1 Installing multipart-post 2.1.1 Installing faraday-net_http 1.0.1 Fetching faraday-net_http_persistent 1.2.0 Fetching faraday-patron 1.0.0 Fetching faraday-rack 1.0.0 Installing faraday-net_http_persistent 1.2.0 Installing faraday-rack 1.0.0 Installing faraday-patron 1.0.0 Fetching faraday-retry 1.0.3 Installing faraday-retry 1.0.3 Fetching ruby2_keywords 0.0.5 Fetching rchardet 1.8.0 Installing ruby2_keywords 0.0.5 Installing rchardet 1.8.0 Fetching hashie 3.6.0 Fetching jwt 2.3.0 Installing hashie 3.6.0 Installing jwt 2.3.0 Fetching multi_json 1.15.0 Installing multi_json 1.15.0 Fetching multi_xml 0.6.0 Fetching rack 2.2.3 Installing multi_xml 0.6.0 Installing rack 2.2.3 Fetching jruby-win32ole 0.8.5 Fetching nested_inherited_jruby_include_package 0.3.0 Installing nested_inherited_jruby_include_package 0.3.0 Installing jruby-win32ole 0.8.5 Fetching os 1.1.4 Installing os 1.1.4 Fetching tty-color 0.6.0 Fetching tty-cursor 0.7.1 Fetching tty-screen 0.8.1 Installing tty-color 0.6.0 Installing tty-cursor 0.7.1 Installing tty-screen 0.8.1 Fetching wisper 2.0.1 Fetching rouge 3.28.0 Fetching method_source 1.0.0 Installing wisper 2.0.1 Installing method_source 1.0.0 Installing rouge 3.28.0 Fetching text-table 1.2.4 Installing text-table 1.2.4 Fetching highline 2.0.3 Installing highline 2.0.3 Using jar-dependencies 0.4.1 Fetching jruby-jars 9.3.4.0 Fetching jruby-rack 1.1.21 Installing jruby-rack 1.1.21 Fetching semver2 3.4.2 Installing semver2 3.4.2 Fetching racc 1.6.0 (java) Installing racc 1.6.0 (java) Fetching rspec-support 3.5.0 Installing rspec-support 3.5.0 Fetching rubyzip 1.3.0 Fetching simplecov-html 0.12.3 Installing rubyzip 1.3.0 Installing simplecov-html 0.12.3 Fetching simplecov_json_formatter 0.1.4 Installing simplecov_json_formatter 0.1.4 Fetching addressable 2.8.0 Fetching puts_debuggerer 0.13.5 Installing puts_debuggerer 0.13.5 Installing addressable 2.8.0 Fetching descendants_tracker 0.0.4 Installing descendants_tracker 0.0.4 Fetching faraday-multipart 1.0.3 Installing faraday-multipart 1.0.3 Fetching git 1.10.2 Fetching pastel 0.8.0 Fetching super_module 1.4.1 Installing git 1.10.2 Installing pastel 0.8.0 Installing super_module 1.4.1 Fetching tty-reader 0.9.0 Fetching psych 4.0.3 (java) Installing tty-reader 0.9.0 Fetching kamelcase 0.0.2 Installing kamelcase 0.0.2 Installing jruby-jars 9.3.4.0 Installing psych 4.0.3 (java) Fetching nokogiri 1.13.4 (java) Fetching rspec-core 3.5.4 Installing rspec-core 3.5.4 jar dependencies for psych-4.0.3-java.gemspec . . . Installing gem 'ruby-maven' . . . Fetching rspec-expectations 3.5.0 Installing rspec-expectations 3.5.0 Installing nokogiri 1.13.4 (java) Fetching rspec-mocks 3.5.0 Installing rspec-mocks 3.5.0 Fetching simplecov 0.21.2 Installing simplecov 0.21.2 Fetching faraday 1.10.0 Installing faraday 1.10.0 Fetching glimmer 2.7.3 Installing glimmer 2.7.3 Fetching tty-prompt 0.23.1 Installing tty-prompt 0.23.1 Fetching rspec 3.5.0 Fetching warbler 2.0.5 Installing rspec 3.5.0 Installing warbler 2.0.5 Fetching oauth2 1.4.9 Fetching rake-tui 0.2.3 Installing rake-tui 0.2.3 Installing oauth2 1.4.9 Fetching glimmer-dsl-swt 4.23.1.4 Fetching github_api 0.19.0 using maven for the first time results in maven downloading all its default plugin and can take time. as those plugins get cached on disk and further execution of maven is much faster then the first time. Installing github_api 0.19.0 Installing glimmer-dsl-swt 4.23.1.4 2022-04-11T20:47:17.877-04:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable. org.yaml:snakeyaml:1.28:compile Fetching rdoc 6.4.0 Installing rdoc 6.4.0 Fetching juwelier 2.4.9 Installing juwelier 2.4.9 Bundle complete! 5 Gemfile dependencies, 74 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Post-install message from glimmer-dsl-swt: [" You are ready to use `glimmer` and `girb` commands on Windows and Linux. On the Mac, run `glimmer-setup` command to complete setup of Glimmer DSL for SWT (it will configure a Mac required jruby option globally `-J-XstartOnFirstThread` so that you do not have to add manually), making `glimmer` and `girb` commands ready for use: glimmer-setup "] exist .rspec create spec/spec_helper.rb Created contact_manager/spec/spec_helper.rb Generated: contact_manager.gemspec Locking gem jar-dependencies by downloading and storing in vendor/jars... lock_jars --vendor-dir vendor/jars Installing gem 'ruby-maven' . . . Installing gem 'ruby-maven-libs' . . . using maven for the first time results in maven downloading all its default plugin and can take time. as those plugins get cached on disk and further execution of maven is much faster then the first time. -- jar root dependencies -- 2022-04-11T20:48:09.018-04:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable. org.yaml:snakeyaml:1.28:compile vendor jars: irb_chws- create vendor/jars/org/yaml/snakeyaml/1.28/snakeyaml-1.28.jar Jars.lock created Generating JAR configuration (config/warble.rb) to use with Warbler... /Users/andymaleh/.rvm/gems/jruby-9.3.4.0@contact_manager/bin/warble cp /Users/andymaleh/.rvm/gems/jruby-9.3.4.0@contact_manager/gems/warbler-2.0.5/warble.rb config/warble.rb Generating JAR with Warbler... /Users/andymaleh/.rvm/gems/jruby-9.3.4.0@contact_manager/bin/warble application directory `db' does not exist or is not a directory; skipping application directory `docs' does not exist or is not a directory; skipping application directory `fonts' does not exist or is not a directory; skipping application directory `images' does not exist or is not a directory; skipping application directory `lib' does not exist or is not a directory; skipping application directory `package' does not exist or is not a directory; skipping application directory `script' does not exist or is not a directory; skipping application directory `sounds' does not exist or is not a directory; skipping application directory `videos' does not exist or is not a directory; skipping rm -f dist/contact_manager.jar Creating dist/contact_manager.jar Generating native executable with jpackage... Java Version 18 Detected! jpackage --type app-image --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar 'contact_manager.jar' --name 'Contact Manager' --vendor 'Contact Manager' --icon 'icons/macosx/Contact Manager.icns' --java-options '-XstartOnFirstThread' --mac-package-name 'Contact Manager' --mac-package-identifier 'org.contact_manager.application.contact_manager' --app-version "1.0.0" --copyright "Copyright (c) 2022 contact_manager" --name 'Contact Manager' --description 'Contact Manager' Launching Glimmer Application: ./bin/contact_manager Launching Glimmer Application: /Users/andymaleh/code/contact_manager/app/contact_manager/launch.rb

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts