Newbie question: Error: Could not find or load main class ...

58 views
Skip to first unread message

Serge Behar

unread,
Aug 7, 2017, 1:19:21 AM8/7/17
to mozilla-rhino
Hi,
I can run class files created with rhino. I can compile, in debian the compiler is named rhino-jsc, it took me a while to find it out.
It runs without errors but when i tried to run the class with "java Hello" file i get a message "Error: Could not find or load main class Hello".
Do I have to declare a package name or a main method in Rhino? How?
Thanks

Gregory Brail

unread,
Aug 7, 2017, 5:35:48 PM8/7/17
to mozill...@googlegroups.com
"jsc" compiles a single script to a single "Script" object that you can load from a .class file and launch as part of a Java app. But the generated code doesn't generate a "main" as you describe.

Jsc does have a facility for you to implement a main method that you write yourself in Java using a different class. Take a look at the "--main-method-class" option.

Indeed it might be interesting to explore how hard it'd be to give jsc the option to generate a "main" that just calls your script and then exits, but it takes a little more work today.


--
You received this message because you are subscribed to the Google Groups "mozilla-rhino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-rhino+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Serge Behar

unread,
Aug 7, 2017, 7:25:35 PM8/7/17
to mozilla-rhino
Thanks, it makes sense.
Another question how do I set the package name for a class in a .js Rhino file. In other words how do i import the class generated from a regular java file?. 
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-rhin...@googlegroups.com.

Gregory Brail

unread,
Aug 8, 2017, 2:29:18 PM8/8/17
to mozill...@googlegroups.com
it looks like the "-o" option does that, as per the "-h" (help) output from the tool.

To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-rhino+unsubscribe@googlegroups.com.

Serge Behar

unread,
Aug 8, 2017, 5:28:06 PM8/8/17
to mozilla-rhino
Thanks, I will research more.
Reply all
Reply to author
Forward
0 new messages