jEdit Community - Resources for users of the jEdit Text Editor
Superscript plugin with javascript (Rhino) fails to work
Submitted by phade on Wednesday, 9 April, 2008 - 16:55
Hello to all users of this excellent editor Smiling

Trying to get SuperScript plugin to work with Rhino:

jEdit4.3pre13 with Java 1.6.0

- Downloaded Rhino 1.7R1 and put the jars js.jar and js-14.jar to ~/.jedit/jars
- Ran jedit from the shell (in order to get output to debug)
- Set superscript script mode to javascript and tried to run print("Hello"), no output in superscript plugin but shell displayed error


java.lang.NoSuchMethodError: org.mozilla.javascript.Context.getDebuggableEngine()Lorg/mozilla/javascript/debug/DebuggableEngine;

- googled and found that I probably should use newer bsf (2.4) (SuperScript has bsf 2.3 included and documentation also states that bsf 2.3+ can be used)
- downloaded newer bsf 2.4.0 and replaced the one in ~/.jedit/jars
- started jedit, it started but displayed error in shell:

7:24:47 PM [error] AWT-EventQueue-0: log4j:WARN No appenders could be found for logger (org.apache.bsf.BSFManager).
7:24:47 PM [error] AWT-EventQueue-0: log4j:WARN Please initialize the log4j system properly.

- tried javascript engine again and got output in superscript

org.apache.bsf.engines.javascript.JavaScriptEngine

- also beanshell engine in superscript did not worked anymore (worked fine with superscript included bsf 2.3) and output to superscript window:

bsh.util.BeanShellBSFEngine

- googled and found out that bsf 2.4.0 needs new common-logging.jar from apache commons, downloaded it (commons-logging-1.1.1.jar) and placed in ~/.jedit/jars

- no change still the error in shell and superscript engines fail to work
- decided to try some manual java trickery:

loaded jedit like this:

java -cp jedit.jar:commons-logging-1.1.1.jar:bsf.jar:bsh-2.0b4.jar:js.jar:js-14.jar org.gjt.sp.jedit.jEdit

(in actual command correct jar paths of course were used)

- that way I got no errors on startup, beanshell engine worked in superscript but rhino javascript (ran print("Hello") still failed displaying:

ReferenceError: "print" is not defined.

and shell displayed:

7:49:35 PM [error] SuperScriptPlugin: JavaScript Error: Internal Error: org.mozilla.javascript.EcmaError: ReferenceError: "print" is not defined.
7:49:35 PM [error] SuperScriptPlugin: org.apache.bsf.BSFException: JavaScript Error: Internal Error: org.mozilla.javascript.EcmaError: ReferenceError: "print" is not defined.


So has anyone got newer bsf or Rhino javascript engine to work with SuperScript? I know that some have got bsf 2.4.0 to work with superscript 0.5pre but I can not find this pre version anywhere.


PS: the shell outputted of course more in all cases but I included only relevant lines in the post. If you want to see more just let me know.

All the best,
Villu
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
some impovements but still not solved
by phade on Thu, 10/04/2008 - 08:11
I actually got rhino to work using this java trickery

java -cp jedit.jar:commons-logging-1.1.1.jar:bsf.jar:bsh-2.0b4.jar:js.jar:js-14.jar org.gjt.sp.jedit.jEdi

The problem was that I thought that print() is part of rhinos js engine but actually it is feature of rhino js shell.

I wrote small (and stupid Smiling) script to test out rhino with bsf and it was evaluated correctly (the array comprehensions stuff is just to see if javascript 1.7 features work correctly).

testf();

testf = function() {
var arr = [i for each (i in ['first','second','last']) if (i != 'second')];
for each (el in arr) {
print(el);
}
}

function print(message) {
java.lang.System.out.println(message);
}


But this is not acceptable solution since I manually have to include all the engines that I want to use. So how can I get it to work without having to specify engines manually?
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82348
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18495
BBEdit scheme   1.0   18116
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293