This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 97335 - enable calling Java from RoR and JRuby projects
Summary: enable calling Java from RoR and JRuby projects
Status: RESOLVED FIXED
Alias: None
Product: ruby
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P3 blocker (vote)
Assignee: Torbjorn Norbye
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-07 01:36 UTC by Pavel Buzek
Modified: 2007-07-03 14:46 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
adding cp to env of jruby execution and to webrick (8.02 KB, patch)
2007-03-08 01:14 UTC, Pavel Buzek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Buzek 2007-03-07 01:36:39 UTC
I am trying to call Java code in my library jar file using the instructions:
http://www.headius.com/jrubywiki/index.php/Calling_Java_from_JRuby

I do not want to copy my jar file into jruby/lib. Ideally I would like to add a
project dependency on a Java Library project or a library from Library Manager
and let the magic happen.

A quick workaround would be to specify the CLASSPATH environment variable for
the jruby process manually. But I did not find a way to do even that.
Comment 1 Pavel Buzek 2007-03-08 01:14:39 UTC
Created attachment 39286 [details]
adding cp to env of jruby execution and to webrick
Comment 2 Pavel Buzek 2007-03-08 01:20:48 UTC
OK, I checked that adding jar file to CLASSPATH env variable does the trick
(diff attached).

Now, the question for Tor is if you are OK with adding Libraries node similar to
the one in Java project into Ruby and RoR project. Perhaps labeled "Java
Libraries". And also adding the Libraries section into project customizer. If
not, what UI would you propose?

Another issue is that if we add Java libraries the user would probably expect
these libraries to be compiled before the Ruby/RoR project is executed. Not a
P1, perhaps, but IMO nice convenience. But if we want that we would need to add
an Ant script to call the dependent project. Are you OK with that?
Comment 3 Torbjorn Norbye 2007-03-10 17:51:59 UTC
I was thinking that Ruby and Rails projects should have a "Enable Java" setting.
(We may have a separate project entry in the New Project wizard for these, e.g.
Ruby Project, and Ruby with Java Libraries project, but they would both use the
same underlying project type).

When "Enable Java" is set on a Ruby project:
- There is a libraries panel where you can import jars and other netbeans
libraries, and these will be added to JRuby's CLASSPATH
- The source indexer will include some JRuby specific extensions to all Objects,
such as the "include_class" method - this will then show up in code completion etc.
- Code completion will be modified to include Java classes in its code
completion. (I'll have to use the java/source stuff to do queries on Java
classes as well and feed the results back into my own Ruby completion dialog.
I'm not sure yet if that will be adequate (to get Java javadoc popups etc.) or
if I need to do anything more clever to pick up all the code completion smarts
in JavaCompletionProvider.
- Possibly the Java Platform to be used (for JRuby execution) should be
selectable and set on the project.
Comment 4 Pavel Buzek 2007-03-10 20:57:26 UTC
Tor, just two comments:

1. IMO the setting should not be only in project template, you should be able to
add Java support to an existing R/RoR project. This is similar to what we do
with web frameworks in web app: you can either select frameworks in the last
panel of porject wizard or (in the same panel) in project properties dialog.

2. I did not check if/why we need the dependency on Java APIs and if we could
get rid of them. Ideally we should keep the Java support separate from the Ruby
and Rails project implementation and make the plain Ruby/Rails projects
independent of Java infrastructure. This will make it easier to build a small
ruby IDE w/o Java. This requires more investigation.
Comment 5 Torbjorn Norbye 2007-06-19 21:43:20 UTC
This is implemented; Ruby and Rails projects now have a separate "Java" panel in their property sheets where you can add in Jars that should be made 
accessible to the JRuby VM. 
Comment 6 Jiri Kovalsky 2007-07-03 14:05:27 UTC
Reassigning this issue to newly created 'ruby' component.
Comment 7 Jiri Kovalsky 2007-07-03 14:46:06 UTC
Changing target milestone of all resolved Ruby issues from TBD to 6.0 Beta 1 build.