【发布时间】:2014-09-15 11:50:03
【问题描述】:
我正在执行来自 jsp(例如:shell.jsp)的以下命令,并且我已经为 tomcat 服务器设置了。 我在 MAC 机器/mac book 中运行。
<%@ page import="java.util.*,java.io.*" %>
<%@ page import="java.lang.Runtime" %>
String unixCommand = "sh /Users/admin/interface.sh";
Runtime rt = Runtime.getRuntime();
rt.exec(unixCommand);
我遇到了错误
An error occurred at line: 9 in the jsp file: /file_upload_download/shell.jsp
**The method exec(String) is undefined for the type Runtime**
String unixCommand = "sh /Users/admin/interface.sh";
Runtime rt = Runtime.getRuntime();
【问题讨论】:
-
您是否导入了正确的
Runtime类? -
我已经导入了 java.lang.Runtime 类,但在 mac 机器/mac book 中仍然无法使用