How to create distribution files(.exe) with jruby

南楼画角 提交于 2020-01-04 08:05:45

问题


I have created a JRuby desktop application. Now I need to install on different platforms(Windows, Linux, Mac). Can any one help me on this

Which is the painless method to create installation files OR executables with jruby. I googled and tried with RubyScript2exe, OCRA but none of these succeeded(really dont understood much). I am a noobie.. I really need it...

EDIT - TRYING A SIMPLE METHOD as jrubyc can create java equivalent class files(described here)

To start with packaging I created a HelloWorld.rb. Below is the file

require 'jruby/core_ext'

swingClasses  = %w(JFrame JPanel JPopupMenu JMenuItem
              BorderFactory JLabel JTree JTextField Box JList 
              JComboBox ImageIcon BoxLayout JPasswordField
              JButton SwingConstants border.LineBorder 
              )
swingClasses.each {|swc| java_import "javax.swing.#{swc}"}
awtClasses    = %w(Color Dimension EventQueue event.ActionListener
    event.ActionEvent event.MouseAdapter)
awtClasses.each {|awc| java_import "java.awt.#{awc}"}

class HelloWorld < JFrame
    def initialize
        super "welcome"

        main_panel = JPanel.new
        main_panel.setLayout BoxLayout.new main_panel, BoxLayout::Y_AXIS

        top_panel = JPanel.new
        top_panel.setLayout nil
        top_panel.setBackground Color.green   
        main_panel.add top_panel

        self.add main_panel
        self.pack
        self.setDefaultCloseOperation JFrame::EXIT_ON_CLOSE
        self.setSize 800,700
        self.setVisible true
    end
end

HelloWorld.new

The file is running fine with the command: jruby HelloWorld.rb. Also I have managed to created .jar file using: jar cvfe HelloWorld.jar HelloWorld HelloWorld.class with the .class file created using: jrubyc HelloWorld.rb

But when I run the jar using: java -jar HelloWorld.jar, I am getting the below error.

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/ParseResult
  at java.lang.Class.getDeclaredMethods0(Native Method)
  at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
  at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
  at java.lang.Class.getMethod0(Class.java:3018)
  at java.lang.Class.getMethod(Class.java:1784)
  at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.jruby.ParseResult
  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 7 more

Please throw me some lights on how to solve this...

EDIT This found to be becouse of the lack of additional files OR classfiles. Didn't find any file/jar named org.jruby.ParseResult in jruby installed. How we can know what all files need to be added for an application as I am not using any particular libraries. I am expecting it to run if JRE installed. Please guide me. Can some one share me what I can do here

来源:https://stackoverflow.com/questions/48223998/how-to-create-distribution-files-exe-with-jruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!