Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 153188 - JRuby main class results in a valid jar which the IDE refuses to run.
JRuby main class results in a valid jar which the IDE refuses to run.
Status: RESOLVED DUPLICATE of bug 151086
Product: ruby
Classification: Unclassified
Component: Project
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Martin Krauskopf
issues@ruby
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-14 01:19 UTC by toholio
Modified: 2009-02-19 23:01 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description toholio 2008-11-14 01:19:25 UTC
A project which has a ruby file which is compiled to be used as the main class then the resulting jar is not runnable
from the IDE. The jar can be executed from the command line and shell correctly but attempting to run it from the IDE
brings up and empty list from which to select the main class.

To reproduce:
1. Create an empty project.
2. Add the jruby jars to the project.
3. Add a package, e.g. 'example'
4. Add a ruby source file, e.g. Main.rb to the package.
5. Add a -pre-compile target to build.xml to call jrubyc for the ruby script (this will generate the main method, etc).
6. Set the project's main class, e.g. example.Main
7. Build the project.
8. Run the project from the command line, e.g. java -jar ExampleProject.jar and it will work fine.
9. Attempt to run the project from the IDE and you will get an empty list which you must select a main class from.

Very annoying.

I'm not sure if it needs to somehow look for the compiled main class or simply have an option to ignore the 'missing'
main class and run anyway.

This may be related to issue 152096.
Comment 1 Peter Pis 2008-11-14 06:30:06 UTC
Reassigning to ruby for evaluation.
Comment 2 Martin Krauskopf 2008-12-08 08:32:33 UTC
Hi, I guess you are speaking about J2SE project in:

> 1. Create an empty project.

where is the case, that jar contains valid (wrt. bytecode) example.Main class which does not have Java source
association and you would like to choose it as a main class when running?

Reassigning to j2seproject, such main class might be generated anyhow (not just with jrubyc).
Comment 3 Tomas Zezula 2008-12-08 10:24:27 UTC
J2SEProject provides java language support. For ruby use ruby project or add the resulting class (the class to be executed) to the runtime libraries.
Comment 4 Martin Krauskopf 2008-12-08 10:36:40 UTC
The cooperation between Ruby and Java from the Ruby project point of view is already tracked in issue 151086. From what
I understand this is about J2SE Project feature. If you are not going to support the following scenario or/and reporter
meant something else then how I understand it, please close as dupe of issue 151086 or wontfix in J2SE project.

(note: no Ruby at all)
1. Create an empty project.
2. Add a -pre-compile target to build.xml which generates 'main' class with
   main method, e.g. example.Main
3. Set the project's main class, e.g. example.Main
4. Build the project.
5. Run the project from the command line, e.g. java -jar ExampleProject.jar and
   it will work fine.
6. Attempt to run the project from the IDE and you will get an empty list which
   you must select a main class from.

Comment 5 Tomas Zezula 2008-12-08 10:39:51 UTC
Again, j2se project provides java based support.
If you want the j2se project to deal with ruby sources (the resulting class came from ruby  and has SFBQ) the ruby module has to provide 
VirtualSourceProvider.
Comment 6 Martin Krauskopf 2008-12-08 11:13:00 UTC
Interoperability between Ruby and Java projects is tracked in the issue 151086. Duping this issue for that.

For now it might work, that you enter name of your in-future-generated-mainclass in J2SE project's properties, which
might be taken when the project is run. But I'm not sure, whether there is check for main class' sources during run.

*** This issue has been marked as a duplicate of 151086 ***
Comment 7 toholio 2008-12-08 22:20:49 UTC
Specifying the main class in the project properties doesn't work. It gets put into the manifest correctly but the IDE is
looking for something else before it will run it.
Comment 8 Martin Krauskopf 2008-12-09 09:08:20 UTC
What is the actual use-case? Do you have a Ruby application with Ruby sources from which you want to build a .jar and
run it through java command? Then I would suggest to rather create a Ruby project with appropriate Rake tasks (probably
something like http://spin.atomicobject.com/2008/07/02/rolling-a-jruby-desktop-application) rather then J2SE project
with Ant targets.

If you have also Java source, I would suggest to develop Java code as a library, a separate jar which you will put on
the Ruby application's LOADPATH.

Anyway we are currently lack better Ruby and Java projects interoperability, which is supposed to be fixed in issue 151086.

Regarding the failed suggestion with J2SE project's mainclass. Likely Java project do some checks for existing sources,
might be creating a fake class which would be regenerated with -post-compile target, or similar hack would work. I do
not know J2SE project enough.
Comment 9 loganbarnett 2008-12-09 20:20:42 UTC
I do almost all of my JRuby projects as a Java project. I use Rawr to help me with this (http://rawr.rubyforge.org/).
Rawr generates a Main.java which in turn runs main.rb (by default, this is configurable).
You can use the Main.java as your main class. You add jruby-complete.jar to your classpath.
When you click play (F6), Netbeans will compile the app and run it as a jar.

I hope this helps your current situation.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo