Search code examples
javarubyjrubygit-submodulesrubymine

Jruby extend java class in another directory using Rubymine


I am somewhat new to RubyMine but here is my problem. I have a JRUBY Class that I want to extend from a Java class. My Java class is part of a submodule I have imported using git. This is my project structure:

src --> Submodule --> <Directories> --> ClassIWantToExtend.java
    --> Ruby Code --> <Directories> --> JRubyClassThatExtendsJava.rb

However, when using RubyMine I have been unable to figure out how to extend this Java class. It can't seem to find it. My current class is blank. This is all I have:

require 'java'

class JRubyClassThatExtendsJava
end

I have tried using '<' and 'include' but when autofilling RubyMine can't seem to find my Java Class. I did just add the submodule using a CLI Git Command. Is it possible I have to add something for RubyMine to see it?

Thanks for any help in advance.


Solution

  • RubyMine, as far as I know (bought a license but never actually used it due this) does not include support for .java (not even a syntax highlighter) - the motivation seems to be that they have a separate product that is a Java IDE. thus this answer is not going to be RubyMine specific :

    • first you'll need to compile the .java sources and either pack them in a .jar or simply keep in mind what directory the .class files are (javac -d OUT_DIR)

    • than in your .rb you can either require 'path/to/packed.jar' or simply $CLASSPATH << 'path/to/classes/OUT_DIR'

    ... than you should be able to load the Java class and extend it in Ruby