在我的java程序中,我大量使用太陽腳本引擎的太陽實現。然而,最近我的JDK在編譯時似乎不再自動導入rt.jar文件。無法在NetBeans中導入sun.org.mozilla.javascript.internal
奇怪的是,NetBeans報告0個實時錯誤,它們只在執行完整的Clean & Build時顯示。當我導入NativeArray時,這並沒有發生,所以我很困惑爲什麼突然停止工作。
規格:
- 操作系統 - 視窗
- Java版本 - Java版本 「1.6.0_20」
- javac的版本 - 的javac 1.6.0_20
- 的NetBeans版本 - 6.9
檢查它是否存在:
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src>javap sun.org.mozill a.javascript.internal.WrappedException Compiled from "WrappedException.java" public class sun.org.mozilla.javascript.internal.WrappedException extends sun.or g.mozilla.javascript.internal.EvaluatorException{ static final long serialVersionUID; public sun.org.mozilla.javascript.internal.WrappedException(java.lang.Throwa ble); public java.lang.Throwable getWrappedException(); public java.lang.Object unwrap(); }
好它的存在,所以這裏的一些測試代碼:
package testapp;
import sun.org.mozilla.javascript.internal.WrappedException;
public class Main {
public static void main(String[] args) {
WrappedException e = new WrappedException(null);
}
}
Netbeans的輸出:
init: deps-clean: Updating property file: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\built-clean.properties Deleting directory C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build clean: init: deps-jar: Created dir: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build Updating property file: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\built-jar.properties Created dir: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\classes Created dir: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\empty Compiling 1 source file to C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\classes C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp\Main.java:8: package sun.org.mozilla.javascript.internal does not exist import sun.org.mozilla.javascript.internal.WrappedException; C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp\Main.java:16: cannot find symbol symbol : class WrappedException location: class testapp.Main WrappedException e = new WrappedException(null); ^ C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp\Main.java:16: cannot find symbol symbol : class WrappedException location: class testapp.Main WrappedException e = new WrappedException(null); ^ 3 errors C:\Documents and Settings\LordQuackstar\Desktop\TestApp\nbproject\build-impl.xml:528: The following error occurred while executing this line: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\nbproject\build-impl.xml:261: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 0 seconds)
命令行輸出:
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp>javac Main.java Main.java:3: package sun.org.mozilla.javascript.internal does not exist import sun.org.mozilla.javascript.internal.WrappedException; ^ Main.java:7: cannot find symbol symbol : class WrappedException location: class testapp.Main WrappedException e = new WrappedException(null); ^ Main.java:7: cannot find symbol symbol : class WrappedException location: class testapp.Main WrappedException e = new WrappedException(null); ^ 3 errors
那麼什麼會導致這種失敗突然?昨天工作得很好。除了從同一個軟件包中導入2個以上的類外,我沒有改變任何東西。我的依賴沒有任何變化。
將在linux中測試,看看問題是否仍然存在。
之前你說:不,我不下載犀牛separatly,沒有我不會改變的IDE,
那麼您如何期望能夠從Java訪問javascript數組而沒有'java.lang.reflect.Array.newInstance(java.lang.String,5);''的荒謬語法?你將如何訪問json對象?你不能。 javax.script不過是一個抽象層。沒有什麼能阻止我使用Sun的命名空間,內部只是一些奇怪的日光管理(org.mozilla和org.mozilla.rhino.internal中沒有類) – TheLQ 2010-07-04 21:30:00
如果抽象不夠,直接使用原始實現 - 下載犀牛並使用它。 – Bozho 2010-07-04 21:40:47
太陽實施工作得很好。我寧願不添加另一個依賴到一個已經很大的默認存在的框架列表中。 – TheLQ 2010-07-04 22:39:09