• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created about 13 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaFX JRuby binding

JRubyFX

JRubyFX is a pure ruby wrapper for JavaFX 2.2+ with FXML support. Currently supported: Java 8+, JRuby 9.3+.

Status

JRubyFX master should be usable in its current form and able to run most FXML apps. As of JRubyFX 2.0, the Java FXML Loader is used. This requires JRuby 9.3+. Please see the JRubyFX github wiki for upgrading from 1.x.

Install

For JRuby 9.3.4+:

gem install jrubyfx

For older JRuby versions:

gem install jrubyfx -v 1.2

If you are using Java 9+, additionally append the contents of module-opens.txt to bin/.jruby.java_opts in your jruby install. If you fail to do this, you may get inscruitable "method X not found, did you mean X?" errors.

Manual Build and Install

Build is done using rake/gem/bundler/rdoc. You need JRuby >= 9.3.4.0, Java >= 8 with JavaFX 11 modules installed (only required for reflect task). Building native application packages requires JDK 8+.

rake install

Once the gem is installed, just run a ruby file that uses it normally.

NOTE: If you don't have JRuby installed as the ruby command, use jruby -S rake instead of rake. If you are using RVM, this does not apply to you (though make sure you rvm use jruby).

If you are reporting bugs or encountering fxml issues: please ensure you are using JRubyFX 2.0. Prior version relied on a ported fxml parser and had many known issues.

Updating the Imports

JRubyFX currently uses the 11-based classes for the default imports (part_imports.rb). In the future, this list may change. See gen_tree.rb for a script to help automate finding the classes to import.

Creating a Jar

If you want to distribute your application, you can create a jar with embedded JRuby. Place all your sources in a folder, and run (replacing paths as appropriate):

jrubyfx-jarify samples/fxml/ --main samples/fxml/Demo.rb Demo.jar

This jar can then run anywhere there is a JVM with JavaFX. Note than the main file is renamed to jar-bootstrap.rb inside the jar. If you need to detect if you are in a jar, use the JRubyFX::Application.in_jar? method.

You can create native application packages and installers. For now, this requires that you have JDK8 installed, although this may change in the near future. Just pass the --native option. The packaging toolkit can only create packages for the OS it is being used on, so for Windows installers you will need to run it on a Windows machine, for OSX installers you will need to run it on a Mac, etc.

In order for the installer to be created, you will need some additional tools installed on your system. For Windows you need either Inno Setup 5 or later for an EXE or Windows Installer XML (WiX) toolset to generate an MSI. Make sure the WiX toolset's bin folder is on the PATH. No special tools are need to generate a DMG, just a recent version of OSX. For linux, the packager uses dpkg-deb to create DEB installers and rpmbuild for RPM.

If you don't want your application to be called "JarBootstrapMain", I highly suggest passing the --name option with an appropriate string.

To customize the package, for example to change the icons or license pass the -v or --verbose option. This will cause the JavaFX packaging tools to enter verbose mode, and provide more details about the process, including (the important part for customization) the location of a temporary folder where the config resources for the build are held and a list of the resources and the role of each. Copy the contents of this tmp folder into a folder in your project directory (the dir you run jrubyfx-jarify from) where the packaging tools will know to look for them. For example, on linux this would be main_project_dir/package/linux. On OSX, it is main_project_dir/package/macosx. So, if I wanted to use a custom icon, I'd replace the default icon with my own, ensuring it has the same name, and place it inside that linux or macosx folder. Then run the build again. You can find more information on customizing at the official Oracle documentation. This blog post may also be helpful, as he goes through the process of customizing an app for both Windows and OSX.

The JavaFX tools provide far more options than are available from this tool. You can create your own rake tasks and access them directly, however. See this article in the JRuby wiki.

Example: If my project directory is Hello, all my files are in src, I have a dist folder created for my jar file, my main file is called HelloWorldApp.rb, my app's name is "Hello World App", and I want the customization info, the command line would look like this:

jrubyfx-jarify src --main src/HelloWorldApp.rb dist/HelloWorldApp.jar --native --name "Hello World App" -v

Also note that you can do this in code, see samples/fxml/Demo.rb for the rake task usage.

Samples

To run sample:

jruby samples/fxml/Demo.rb

Or, if you have not installed the gem, or are testing edits to jrubyfx.rb:

rake run main_script=samples/fxml/Demo.rb

To run all samples (a nice quick way to make sure you didn't break anything), run:

jruby -I lib samples/test_all_the_samples.rb

Several other files that can be used as examples are in the tests/ folder

Creating Application and Controller

Require the 'jrubyfx' file/gem, and subclass JRubyFX::Application (and JRubyFX::Controller if you are using FXML). At the bottom of the file, call yourFXApplicationClass.launch(). Override start(stage) in the application. See samples/fxml/Demo.rb for commented FXML example, or the fils in samples/javafx for non-FXML (programatic JavaFX, but you should really look into FXML, its better) or see the Getting Started Guide and the Syntax Notes on the JRubyFX github wiki

If you want rdoc, run rake rdoc. Please note that there are lots of generated methods and conventions that are not in the RDoc. Please read the Getting Started Guide or the tutorials.

Issues

  • Errors loading JavaFX are bugs. Please report if you encounter this issue, tell us your platform, OS, and version of JRuby
  • Jarify command needs the jar executable in your path.
  • Any other difficulties are bugs. Please report them

Contact

Find us in #jruby on matrix.

License

Main code is Apache 2.0. See LICENSE. Some samples in contrib may have other licenses.

Authors

  • Patrick Plenefisch (byteit101)
  • Thomas E Enebo (enebo)
  • Hiro Asari (BanzaiMan or asarih)
  • Jeremy Ebler (whitehat101)
  • Hiroshi Nakamura (nahi)
  • Eric West (e_dub or edubkendo)

More Repositories

1

jruby

JRuby, an implementation of Ruby on the JVM
Ruby
3,776
star
2

warbler

Warbler chirpily constructs .war files of your Ruby applications.
Ruby
881
star
3

activerecord-jdbc-adapter

JRuby's ActiveRecord adapter using JDBC.
Ruby
462
star
4

jruby-rack

Rack for JRuby and Java appservers
Ruby
397
star
5

joni

Java port of Oniguruma regexp library
Java
166
star
6

jruby-maven-plugins

maven plugin to handle rubygems in a maven way. including support for rspec, rails, cucumber, rake, etc
Java
112
star
7

jruby-lint

See how ready your Ruby code is to run on JRuby
Ruby
101
star
8

heroku-buildpack-jruby

Shell
63
star
9

jruby-ossl

DEFUNCT, new repository at:
47
star
10

jruby-openssl

JRuby's OpenSSL gem
Java
45
star
11

jruby-parser

JRuby's parser customized for IDE usage
Java
44
star
12

maven_gem

A RubyGems plugin (and a utility) to install Maven artifacts as RubyGems
Ruby
40
star
13

perfer

Ruby
31
star
14

image_voodoo

ImageScience-compatible image processing for JRuby
Ruby
26
star
15

jruby-launcher

JRuby's native launcher executable
C++
24
star
16

jcodings

Java-based codings helper classes for Joni and JRuby
Java
20
star
17

using_jruby

Code samples from the "Using JRuby" book
Ruby
19
star
18

java_inline

JVM language support for RubyInline
Ruby
19
star
19

docker-jruby

Dockerfile
18
star
20

jruby-debug

JRuby-based backend for ruby-debug
Java
15
star
21

jruby-rails-templates

App templates for JRuby on Rails applications
Ruby
14
star
22

maven-tools

ruby helpers for maven related tasks
Ruby
14
star
23

jruby-mains

a couple of main methods for embedded (j)ruby inside a jar/war file
Ruby
10
star
24

jruby-ldap

JRuby/LDAP is a native LDAP implementation that uses JNDI to implement a Ruby/LDAP compatible API.
Ruby
10
star
25

bytelist

DEPRECATED: JRuby no longer maintains org.jruby.util.ByteList as a separate library
Java
10
star
26

rubygems-servlets

webapp which hosts rubygems or a proxy to rubygems. delivers gem maven artifacts as well
Java
9
star
27

jruby-demos

Demos for JRuby presentations at conferences
Ruby
8
star
28

jruby-dashboard

A Dashing dashboard for JRuby applications.
JavaScript
8
star
29

rubybench

Ruby
7
star
30

jrubyhub

Rails 3 + JRuby open source application
Ruby
7
star
31

blog.jruby.org

This is the site and data for blog.jruby.org
CSS
7
star
32

jruby-cext

The MRI C extension subsystem for JRuby
C++
7
star
33

collateral

Public collateral for JRuby
6
star
34

jruby-examples

A collection of examples to help you get the most out of JRuby
Java
5
star
35

jruby-workshop

Course material for JRuby workshop at RubyConf AU 2013
Ruby
4
star
36

jruby-startup

A collection of utilities to help improve JRuby startup time
Ruby
4
star
37

jruby-cdc

A stripped-down version of JRuby that runs on Java ME's CDC profile
Ruby
4
star
38

jruby-graal

Java
4
star
39

jruby-visualizer

Visualize JRuby's runtime in action
Ruby
4
star
40

jrubyconf.com

JRubyConf web sites and collateral
JavaScript
3
star
41

mavengem

Mavengem protocol and mavengem wagon
Ruby
3
star
42

jay

Jay grammar/parser tool
C
2
star
43

jruby-mac-installer

Ruby
2
star
44

dbm

DBM extension for JRuby
Java
2
star
45

jruby-prism

Java parts of integrating the Prism parser into JRuby. Plugs in using an SPI
Java
2
star
46

jruby-async-profiler

A Ruby gem for JRuby that installs the JVM async-profiler extension
Ruby
1
star
47

ruby-maven

Ruby
1
star
48

jzlib

JRuby's fork of the jzlib pure-Java zlib library
Java
1
star
49

gitosis-admin

Gitosis setup for jruby.org
1
star
50

jbang-catalog

Catalog for jbang command line launcher
1
star
51

jruby-readline

JRuby's `readline` library
Java
1
star