我在 netbeans 项目的一个包中有 2 个 java 程序。1个是Run.java,另一个是JdbcSqlServerConnectivity.java。我提到了关于这个主题的早期问题,但似乎没有一个解决方案有效。我收到以下错误
javac JdbcSqlServerConnectivity.java stderr: javac: file not found: JdbcSqlServerConnectivity.java
javac JdbcSqlServerConnectivity.java stderr: Usage: javac <options> <source files>
javac JdbcSqlServerConnectivity.java stderr: use -help for a list of possible options
javac JdbcSqlServerConnectivity.java exitValue() 2
java JdbcSqlServerConnectivity stderr: Error: Could not find or load main class JdbcSqlServerConnectivity
java JdbcSqlServerConnectivity exitValue() 1
运行.java代码
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Run {
private static void printLines(String name, InputStream ins) throws Exception {
String line;
BufferedReader in = new BufferedReader(
new InputStreamReader(ins));
while ((line = in.readLine()) != null) {
System.out.println(name + " " + line);
}
}
private static void runProcess(String command) throws Exception {
Process pro = Runtime.getRuntime().exec("/" + command + "");
printLines(command + " stdout:", pro.getInputStream());
printLines(command + " stderr:", pro.getErrorStream());
pro.waitFor();
System.out.println(command + " exitValue() " + pro.exitValue());
}
public static void main(String[] args) {
try {
runProcess("javac JdbcSqlServerConnectivity.java");
runProcess("java JdbcSqlServerConnectivity");
} catch (Exception e) {
e.printStackTrace();
}
}
}
提前致谢