尝试在 ubbuntu 12.04 上编译 java 程序时遇到以下错误。. 为了便于使用,我将所有类与 java 程序放在同一目录中。我将提供错误消息、主要的 java 程序以及类列表。我删除了前几行注释,因此错误消息的行号不匹配。我对导入语句“评分请求”和“评分响应”有问题
这里也是环境输出
JAVA_HOME=/usr/local/java/jdk1.7.0_10
CLASSPATH=:/home/syedk/WEKA/weka-3-7-9/mysql-connector-java-3.1.17-bin.jar
Error message
=============
javac Scoring.java
Scoring.java:37: error: '.' expected
import ScoringRequest;
^
Scoring.java:37: error: ';' expected
import ScoringRequest;
^
Scoring.java:38: error: class, interface, or enum expected
import ScoringResponse;
^
3 个错误
package Scoring;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ScoringRequest;
import ScoringResponse;
@WebServlet( name="Scoring", displayName="Scoring Servlet", urlPatterns = {"/Scoring"}, loadOnStartup=1)
public class Scoring extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
BufferedReader reader = null;
BufferedWriter writer = null;
ScoringRequest req = null;
try {
reader = new BufferedReader(new InputStreamReader(
request.getInputStream()));
StringBuffer xml = new StringBuffer();
String line = reader.readLine();
while (line != null) {
xml.append(line);
line = reader.readLine();
}
req = new ScoringRequest(xml.toString(), null, null,
null);
ScoringResponse res = (new ScoringEngine()).score(req);
writer = new BufferedWriter(new OutputStreamWriter(
response.getOutputStream()));
writer.write(res.toXML());
writer.flush();
} catch (Exception ex) {
System.err.println(ex);
ScoringResponse res = new ScoringResponse(req.getModelName(), req.getPmmlURL(), req.getCsvInputRows(), null);
StringWriter errWriter = new StringWriter();
ex.printStackTrace(new PrintWriter(errWriter));
res.setErrorMessage(errWriter.toString());
// res.setErrorMessage(ex.getMessage());
writer = new BufferedWriter(new OutputStreamWriter(
response.getOutputStream()));
writer.write(res.toXML());
writer.flush();
} finally {
try {
if (reader != null)
reader.close();
} catch (Exception ex) {
}
try {
if (writer != null)
writer.close();
} catch (Exception ex) {
}
}
}
}