Rhino:脚本从命令行运行,但不从浏览器运行 [英] Rhino: Script runs from command line, but not from browser
问题描述
我有一个简短的JS程序,从命令行运行良好:
#!/ usr / bin / java org.mozilla.javascript.tools.shell.Main
print(" Hello World");
我将其保存为HelloWorld.js。 (这是shabang使它成为一个
JavaScript程序,而不是.js。)
但是,如果我从Safari或Firefox启动它,我在日志中收到以下
消息:
线程中的异常main java.lang.NoClassDefFoundError:org / mozilla /
javascript / tools / shell / Main
有什么想法吗?
(网络服务器是Mac上的Apache)
I have a short JS program that runs fine from the command line:
#!/usr/bin/java org.mozilla.javascript.tools.shell.Main
print("Hello World");
I saved it as HelloWorld.js. (It''s the shabang that makes it a
JavaScript program, not the .js.)
However, if I start it from Safari or Firefox, I get the following
message in the log:
Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/
javascript/tools/shell/Main
Any ideas?
(The webserver is Apache on a Mac)
推荐答案
9月29日9:54 pm,g .. 。@ nsbasic.com" < g ... @ nsbasic.comwrote:
On Sep 29, 9:54 pm, "g...@nsbasic.com" <g...@nsbasic.comwrote:
有什么想法吗?
Any ideas?
从HelloWorld.js中删除第一行,然后它应该在你的浏览器中运行
。
如果要从命令行执行脚本:
/ usr / bin / java org.mozilla.javascript.tools.shell.Main HelloWorld.js
或者我是否误解了这个问题?
Remove the first line from the HelloWorld.js, then it should run in
your browser.
If you want to execute the script from the command line:
/usr/bin/java org.mozilla.javascript.tools.shell.Main HelloWorld.js
Or am I misunderstanding the problem?
gh @nsbasic。 com 写道:
我有一个简短的JS程序,从命令行运行良好:
# !/ usr / bin / java org.mozilla.javascript.tools.shell.Main
print(" Hello World");
我保存了它作为HelloWorld.js。 (这是shabang使它成为一个
JavaScript程序,而不是.js。)
I have a short JS program that runs fine from the command line:
#!/usr/bin/java org.mozilla.javascript.tools.shell.Main
print("Hello World");
I saved it as HelloWorld.js. (It''s the shabang that makes it a
JavaScript program, not the .js.)
这是_shebang_它是一个Java程序,它接受JavaScript
代码作为输入(通过运行JavaScript shell)。这与
是(服务器端)JavaScript脚本不同。
It is the _shebang_ that makes it a Java program that accepts JavaScript
code as input (by running the JavaScript shell). That is different from
being a (server-side) JavaScript script.
但是,如果我从Safari或Firefox启动它,我在日志中获得以下
消息:
线程中的异常main java.lang.NoClassDefFoundError:org / mozilla /
javascript / tools / shell / Main
However, if I start it from Safari or Firefox, I get the following
message in the log:
Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/
javascript/tools/shell/Main
这是一个Java问题,所以关闭 - 话题在这里。检查你的CLASSPATH变量
或使用`java''命令的-classpath参数。
http://www.mozilla.org/rhino/
PointedEars
-
"使用任何版本的Microsoft Frontpage创建您的站点。 (这不会是b $ b阻止人们查看你的来源,但是没有人会想要窃取它。)"
- 来自< http:// www.vortex-webdesign.com/help/hidesource.htm>
This a Java problem, and so off-topic here. Check your CLASSPATH variable
or use the -classpath argument for the `java'' command.
http://www.mozilla.org/rhino/
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won''t
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
这个怎么样:
#!/ usr / bin / java org.mozilla.javascript.tools.shell.Main
alert(Hello World!...哦,该死的,我已经在服务器端弹出: -
(。有人可以来数据中心并点击我吗?
帮助!");
How about this one:
#!/usr/bin/java org.mozilla.javascript.tools.shell.Main
alert("Hello World! ... oh, damn, I''ve popped up on the server side :-
( . Can someone come over to the datacenter and click me away, please?
Help!");
这篇关于Rhino:脚本从命令行运行,但不从浏览器运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!