我在JSP中使用windows命令行参数,我在使用Eclipse编辑和运行时都正常,退出Eclipse后运行却错误。我的代码:<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" import="java.*"%><html>
<head>
<title>C Trainer Online Jurdge - V1.0 </title>
</head> <body>
<%
//执行cmdline
String commandstr = "D:/Tc2/tcc.exe ZZZZ.C > ZZZZ.txt";
Process p ;
try {
p = Runtime.getRuntime().exec(commandstr);
%>
编译结束!
<%
catch (Exception e) {
out.println(e.toString());
%>
编译出错!
<% }
%>
Jurdge page!
</body>
</html>
请各位高手点破
<%@ page import="java.sql.*" import="java.*"%><html>
<head>
<title>C Trainer Online Jurdge - V1.0 </title>
</head> <body>
<%
//执行cmdline
String commandstr = "D:/Tc2/tcc.exe ZZZZ.C > ZZZZ.txt";
Process p ;
try {
p = Runtime.getRuntime().exec(commandstr);
%>
编译结束!
<%
catch (Exception e) {
out.println(e.toString());
%>
编译出错!
<% }
%>
Jurdge page!
</body>
</html>
请各位高手点破
%>
编译结束!
<% <-- 这里少个 }
p = Runtime.getRuntime().exec(commandstr);
%>
编译结束!
<%
}
catch (Exception e) {
out.println(e.toString());
%>
编译出错!
<% }
%>
Jurdge page!
</body>
</html>
当前路径是java虚拟机运行时的工作目录,可通过下列方式取得:
System.getProperty("user.dir")
在Eclipse中,当前路径即为Eclipse的工作目录。指定文件路径就可以解决这个问题:
String commandstr = "D:/Tc2/tcc.exe -Id:\\tc2\\include -Ld:\\tc2\\lib d:\\xxx\\ZZZZ.C > d:\\xxxx\\ZZZZ.txt";
其中xxxx是ZZZZ.C文件所在的目录。
还是有问题啊,系统提示"nvtdm.exe 出错,设置环境出错".
郁闷死了=_=!