无法在 NetBeans 中导入 sun.org.mozilla.javascript.internal [英] Can't import sun.org.mozilla.javascript.internal in NetBeans

查看:30
本文介绍了无法在 NetBeans 中导入 sun.org.mozilla.javascript.internal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 java 程序中,我大量使用了 Suns 对 Rhino 脚本引擎的实现.然而最近,我的JDK在编译时似乎不再自动导入rt.jar文件.

In my java program I make heavy use of Suns implmentation of the Rhino script engine. Very recently however, my JDK does not seem to automatically import the rt.jar file anymore when compiling.

奇怪的是,NetBeans 报告了 0 个实时错误,它们仅在执行完整的 Clean & 时才会出现.建造.之前我在导入 NativeArray 时没有发生这种情况,所以我真的很困惑为什么它突然停止工作.

Whats strange is that NetBeans reports 0 live errors, they only show up when doing a complete Clean & Build. This wasn't happening before when I was importing NativeArray, so I'm really confused on why it all of a sudden stopped working.

规格:

  • 操作系统 - Windows
  • Java 版本 - Java 版本1.6.0_20"
  • Javac 版本 - javac 1.6.0_20
  • NetBeans 版本 - 6.9

检查是否存在:


C:Documents and SettingsLordQuackstarDesktopTestAppsrc>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();
}

好的,它存在,所以这里有一些测试代码:

Ok it exists, so here's some test code:

package testapp;

import sun.org.mozilla.javascript.internal.WrappedException;

public class Main {
    public static void main(String[] args) {
        WrappedException e = new WrappedException(null);
    }
}

Netbeans 输出:

Netbeans output:


init:
deps-clean:
Updating property file: C:Documents and SettingsLordQuackstarDesktopTestAppuilduilt-clean.properties
Deleting directory C:Documents and SettingsLordQuackstarDesktopTestAppuild
clean:
init:
deps-jar:
Created dir: C:Documents and SettingsLordQuackstarDesktopTestAppuild
Updating property file: C:Documents and SettingsLordQuackstarDesktopTestAppuilduilt-jar.properties
Created dir: C:Documents and SettingsLordQuackstarDesktopTestAppuildclasses
Created dir: C:Documents and SettingsLordQuackstarDesktopTestAppuildempty
Compiling 1 source file to C:Documents and SettingsLordQuackstarDesktopTestAppuildclasses
C:Documents and SettingsLordQuackstarDesktopTestAppsrc	estappMain.java:8: package sun.org.mozilla.javascript.internal does not exist
import sun.org.mozilla.javascript.internal.WrappedException;
C:Documents and SettingsLordQuackstarDesktopTestAppsrc	estappMain.java:16: cannot find symbol
symbol  : class WrappedException
location: class testapp.Main
                WrappedException e = new WrappedException(null);
                ^
C:Documents and SettingsLordQuackstarDesktopTestAppsrc	estappMain.java:16: cannot find symbol
symbol  : class WrappedException
location: class testapp.Main
                WrappedException e = new WrappedException(null);
                                         ^
3 errors
C:Documents and SettingsLordQuackstarDesktopTestApp
bprojectuild-impl.xml:528: The following error occurred while executing this line:
C:Documents and SettingsLordQuackstarDesktopTestApp
bprojectuild-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

命令行输出:


C:Documents and SettingsLordQuackstarDesktopTestAppsrc	estapp>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 个类之外,我没有改变任何东西.我的依赖项都没有改变.

So what would cause this to fail all of a sudden? It was working just fine yesterday. I didn't change anything besides importing 2 more classes from the same package. None of my dependencies changed.

将在linux下进行测试,看问题是否仍然存在.

Will test in linux to see if the problem still exists.

在你说之前:不,我不会单独下载犀牛,不,我不会改变 IDE,

Before you say it: No I'm not download rhino separatly, No I'm not changing IDEs,

推荐答案

有两个迹象表明你不应该使用这个类:suninternal - 这意味着这是一些不应被第三方使用的内部类.因为它可以在将来的版本中更改或删除 - 即这不是 API 的一部分.所以 - 单独下载 Rhino.

There are two indications that you shouldn't use this class: sun and internal - these mean that this is some internal class that shouldn't be used by third parties. Because it can change or be removed in future releases - i.e. this is not part of an API. So - download Rhino separately.

如果您使用脚本 API - 仅使用 API 类/接口 - 即 javax.script

If you are using the scripting API - use only the API classes/interfaces - i.e. javax.script

这篇关于无法在 NetBeans 中导入 sun.org.mozilla.javascript.internal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆