使用另一个java文件运行java文件时出错

使用另一个java文件运行java文件时出错,java,error-handling,Java,Error Handling,实际上,我正在尝试在windows中使用另一个java文件运行我的java文件……以下是我的代码: private static void printLines(String name, InputStream ins) throws Exception { String line = null; BufferedReader in = new BufferedReader( new InputStreamReader(ins)); while ((lin

实际上,我正在尝试在windows中使用另一个java文件运行我的java文件……以下是我的代码:

private static void printLines(String name, InputStream ins) throws Exception {
    String line = null;
    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 {
      String s=System.getProperty("user.dir");
      s="C:\\Users\\HP\\Downloads\\apache-tomcat-7.0.54-windows-x64\\apache-tomcat-7.0.54\\webapps\\Mazil4.0\\WEB-INF\\classes";
  File workingDir = new File(s);
  System.out.println(q);
  //new Foo().nonStaticMethod();
Process pro = Runtime.getRuntime().exec(command,null,workingDir);

printLines(command + " stdout:", pro.getInputStream());
printLines(command + " stderr:", pro.getErrorStream());
pro.waitFor();
System.out.println(command + " exitValue() " + pro.exitValue());


 }


  public static void mai(String[] args) {

      String[] credentials=new String[4];int k=0;
      for (String s: args) {
          System.out.println(s);
        credentials[k]=s;k++;
    if(k==4)
    break;
      }


    try {
      //runProcess("javac test2.java");
        //thread foo=new thread();
      runProcess("java mainclasses.emaildownload "+credentials[0]+" "+credentials[1]+" "+credentials[2]+" "+credentials[3]+" ");

    } catch (Exception e) {
      e.printStackTrace();
    }System.out.println("hI");
  }
我使用workingDir…给出类的位置,我的文件路径是:

C:\Users\HP\Downloads\apache-tomcat-7.0.54-windows-x64\apache-tomcat-7.0.54\webapps\Mazil4.0\WEB-INF\classes\mainclasses\emaildownload.class
包名为mainclasses。但它仍然给出错误:

could not find or load main class mainclasses.emaildownload
原因可能是什么?

在这一行:

public static void mai(String[] args) {
缺少一个“n”

改为

public static void main(String[] args) {

我相信命令应该是这样的:

java -cp <path-to-jar> <main-class>
java -cp C:\Users\HP\Downloads\apache-tomcat-7.0.54-windows-x64\apache-tomcat-7.0.54\webapps\Mazil4.0\WEB-INF\classes\<jar-file> mainclasses.emaildownload

这并不是问题所在,实际上我在jsp中使用它,所以我只希望这样,您可以从jsp调用main方法吗?我所做的是thread.mai(id);其中,thread是String[]类型的类名和id,这个实现有什么问题,应该是这样的:java-cp/。mainclasses.emaildownload对不起,我不知道你是什么意思。你在问问题吗?我将更新我的帖子。emaildownload是主类名吗?
java -cp "C:\Users\HP\Downloads\apache-tomcat-7.0.54-windows-x64\apache-tomcat-7.0.54\webapps\Mazil4.0\WEB-INF\classes\*" mainclasses.emaildownload