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.
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.
Reassigning to ruby for evaluation.
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).
J2SEProject provides java language support. For ruby use ruby project or add the resulting class (the class to be executed) to the runtime libraries.
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.
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.
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 ***
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.
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.
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.