package de
import javax
import javax
import javax
import java
import java
import java
import java
import java
public class AjavaEvalScriptFile {
public static void main(String[] args) {
//獲得一個JavaScript腳本引擎
ScriptEngineManager manager = new ScriptEngineManager()
ScriptEngine engine = manager
try {
//創建JS文件的File對象
File script = new File(
Reader reader = new FileReader(script)
//開始執行ajava
engine
} catch (FileNotFoundException e) {
e
} catch (ScriptException e) {
e
}
}
}
ajava
print(
運行結果
控制台
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25542.html