我在myeclipse下找不到javax.script.*,请大虾帮忙!!!

具体类

package other;

import javax.script.*;
import java.io.*;

// Evaluate a file of JavaScript and print its result
public class RunScript {
    public static void main(String[] args) throws IOException {
        // Obtain an interpreter or "ScriptEngine" to run the script.
        ScriptEngineManager scriptManager = new ScriptEngineManager( );
        ScriptEngine js = scriptManager.getEngineByExtension("js");

        // The script file we are going to run
        String filename = null;

        // A Bindings object is a symbol table for or namespace for the
        // script engine. It associates names and values and makes
        // them available to the script.
        Bindings bindings = js.createBindings( );

        // Process the arguments. They may include any number of
        // -Dname=value arguments, which define variables for the script.
        // Any argument that does not begin with -D is taken as a filename
        for(int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (arg.startsWith("-D")) {
                int pos = arg.indexOf('=');
                if (pos == -1) usage( );
                String name = arg.substring(2, pos);
                String value = arg.substring(pos+1);
                // Note that all the variables we define are strings.
                // Scripts can convert them to other types if necessary.
                // We could also pass a java.lang.Number, a java.lang.Boolean
                // or any Java object or null.
                bindings.put(name, value);
            }
            else {
                if (filename != null) usage( ); // only one file please
                filename = arg;
            }
        }
        // Make sure we got a file out of the arguments.
        if (filename == null) usage( );

        // Add one more binding using a special reserved variable name
        // to tell the script engine the name of the file it will be executing.
        // This allows it to provide better error messages.
        bindings.put(ScriptEngine.FILENAME, filename);

        // Get a stream to read the script.
        Reader in = new FileReader(filename);

        try {
            // Evaluate the script using the bindings and get its result.
            Object result = js.eval(in, bindings);
            // Display the result.
            System.out.println(result);
        }
        catch(ScriptException ex) {
            // Or display an error message.
            System.out.println(ex);
        }
    }

    static void usage( ) {
        System.err.println(
                 "Usage: java RunScript [-Dname=value...] script.js");
        System.exit(1);
    }
}


报错:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
 ScriptEngineManager cannot be resolved to a type
 ScriptEngineManager cannot be resolved to a type
 ScriptEngine cannot be resolved to a type
 Bindings cannot be resolved to a type
 ScriptEngine cannot be resolved
 ScriptException cannot be resolved to a type
 ex cannot be resolved

 at other.RunScript.main(RunScript.java:10)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> <entry key="app_preset_prof_preset_name">NewAESUtil (1) Launch Configuration</entry> <entry key="app_preset_prof_preset_filter_s"/> <entry key="app_preset_prof_preset_filter_p">com.tool.Document.*, com.tool.ModerateTask.*, com.tool.PanelDisplay.*, com.tool.PlayerKill.*, com.tool.Stall.*, com.tool.btn.*, com.tool.image.*, com.tool.pet.*, com.tool.role.*, com.tool.tcp.*, com.tool.time.*, come.tool.BangBattle.*, come.tool.Fighting.*, come.tool.JDialog.*, come.tool.Scene.*, come.tool.handle.*, come.tool.map.*, org.cbg.bean.*, org.cbg.btn.*, org.cbg.control.*, org.cbg.entity.*, org.cbg.frame.*, org.cbg.mouslisten.*, org.cbg.panel.*, org.cbg.until.*, org.come.Frame.*, org.come.Jpanel.*, org.come.action.*, org.come.bean.*, org.come.control.*, org.come.daily.*, org.come.entity.*, org.come.good.*, org.come.login.*, org.come.model.*, org.come.mouslisten.*, org.come.npc.*, org.come.socket.*, org.come.starcard.*, org.come.strength.*, org.come.summonequip.*, org.come.test.*, org.come.thread.*, org.come.until.*, org.come.view.*, org.gemstone.btn.*, org.gemstone.mouseListener.*, org.gemstone.panel.*, org.lottery.btn.*, org.lottery.frame.*, org.lottery.mouseListener.*, org.lottery.panel.*, org.skill.btn.*, org.skill.frame.*, org.skill.panel.*, org.soaring.btn.*, org.soaring.panel.*, org.wing.btn.*, org.wing.mouseListener.*, org.wing.panel.*</entry> <entry key="app_preset_prof_preset_alloc_p">10</entry> <entry key="app_preset_"/> <entry key="app_preset_prof_preset_samplingRefreshRate_s">1000</entry> <entry key="app_preset_prof_preset_stacks_p">false</entry> <entry key="app_preset_prof_preset_roots_p">com.tool.Document.** com.tool.ModerateTask.** com.tool.PanelDisplay.** com.tool.PlayerKill.** com.tool.Stall.** com.tool.btn.** com.tool.image.** com.tool.pet.** com.tool.role.** com.tool.tcp.** com.tool.time.** come.tool.BangBattle.** come.tool.Fighting.** come.tool.JDialog.** come.tool.Scene.** come.tool.handle.** come.tool.map.** org.cbg.bean.** org.cbg.btn.** org.cbg.control.** org.cbg.entity.** org.cbg.frame.** org.cbg.mouslisten.** org.cbg.panel.** org.cbg.until.** org.come.Frame.** org.come.Jpanel.** org.come.action.** org.come.bean.** org.come.control.** org.come.daily.** org.come.entity.** org.come.good.** org.come.login.** org.come.model.** org.come.mouslisten.** org.come.npc.** org.come.socket.** org.come.starcard.** org.come.strength.** org.come.summonequip.** org.come.test.** org.come.thread.** org.come.until.** org.come.view.** org.gemstone.btn.** org.gemstone.mouseListener.** org.gemstone.panel.** org.lottery.btn.** org.lottery.frame.** org.lottery.mouseListener.** org.lottery.panel.** org.skill.btn.** org.skill.frame.** org.skill.panel.** org.soaring.btn.** org.soaring.panel.** org.wing.btn.** org.wing.mouseListener.** org.wing.panel.** </entry> <entry key="profiler.settings.instrument.empty.methods">false</entry> <entry key="myeclipse.profiling.mode">0</entry> <entry key="profiler.settings.istrument.getter.setter.methods">false</entry> <entry key="app_preset_prof_preset_samplingRate_s">100</entry> <entry key="app_preset_prof_preset_filterMode_s">true</entry> <entry key="app_preset_prof_preset_selector"/> <entry key="app_preset_prof_preset_refreshRate_s">1000</entry> <entry key="app_preset_prof_preset_runnables_p">true</entry> <entry key="app_preset_prof_preset_filterMode_p">false</entry> <entry key="app_preset_prof_preset_memoryMode_p">true</entry> </properties>
03-20

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值