Netbeans编译并执行正常;但我不能在命令行编译

时间:2014-06-11 21:19:13

标签: java javac

Netbeans编译并运行我的项目。但我无法从命令行编译,可能是因为我从一年前开始Java以来​​一直依赖Netbeans进行编译,并且几乎没有命令行经验。 Mea culpa;但是我整个下午都在谷歌搜索和重读之间挣扎。我的文字说:

如果程序的所有源文件都在当前目录中,则编译包含main()定义的文件将编译该程序的所有源文件。

所以,如果这不正确,那是什么?

这是目录结构:

C:\Users\Dov\Documents\!Docs\NetBeansProjects\Tictactoe\src\GridLayout3x3>dir
 Volume in drive C is C:
 Volume Serial Number is C43F-51D2

 Directory of C:\Users\Dov\Documents\!Docs\NetBeansProjects\Tictactoe\src\GridLa
yout3x3

12/09/2013  05:19 PM    <DIR>          .
12/09/2013  05:19 PM    <DIR>          ..
06/11/2014  04:59 PM             1,730 Check.java
06/11/2014  05:01 PM             4,619 GridLayout3x3.java
               2 File(s)          6,349 bytes

这是我试图编译和我得到的错误:

C:\Users\Dov\Documents\!Docs\NetBeansProjects\Tictactoe\src\GridLayout3x3>javac
GridLayout3x3.java
GridLayout3x3.java:140: error: cannot find symbol

    if (Check.didWin(who)){
        ^
  symbol:   variable Check

  location: class GridLayout3x3

1 error

以下是代码的重要部分:

package GridLayout3x3;

...

public class GridLayout3x3 implements ActionListener {

...

  public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        who = 0;
        new GridLayout3x3();
      }
    });
  }

  public void actionPerformed(ActionEvent e) {
    int row, col;

    xGoesFirstFrame.setVisible(false);

    if (e.getActionCommand().startsWith("Ref")) {
      guiFrame.dispose();
      who = 0;
      new GridLayout3x3();//      main(null);
    }
    if (e.getActionCommand().startsWith("Con")) {
      winnerFrame.setVisible(false);
      jackFrame.setVisible(false);
      return;
    }
    String r = e.getActionCommand().substring(1, 2);
    String c = e.getActionCommand().substring(2, 3);
    try {
      row = Integer.parseInt(r);      col = Integer.parseInt(c);
    }
    catch (NumberFormatException ex) {
      return;
    }
    if (!button[row - 1][col - 1].getText().isEmpty())
      return;
    button[row - 1][col - 1].setText(player.substring(who, who + 1));



    if (Check.didWin(who)){ // error right here ********************



      declareWinner(who);
      who = 1;
    }
    who = 1 - who;
  }
} // end class



package GridLayout3x3;

import static GridLayout3x3.GridLayout3x3.*;

public class Check {
...



  public static boolean didWin(int w) { // calling this *********************



    boolean maybe;
    maybe = checkRows(w) || checkCols(w) || checkDiags(w);
    if (maybe) {
      return true;
    }
    for (int r = 0; r < 3; r++) {
      for (int c = 0; c < 3; c++) {
        if (button[r][c].getText().isEmpty()) {
          return false;
        }
      }
    }
    jackFrame.setVisible(true);
    return false;
  }  
}  

我做错了什么?????

我很乐意提交整个程序,但肯定有一些明显的东西。

0 个答案:

没有答案