Results 1 to 7 of 7

Thread: JAR File Help

  1. #1
    Join Date
    Dec 2013
    Posts
    16
    Rep Power
    0

    Default JAR File Help

    I have some problems with this code can anyone help me fix them.


    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;

    import games.board.*;



    public class TictacToeGUIGame extends JFrame {




    //Declare the following instance variables in
    private Board gb;
    private int turn;
    //Add the following method to handle each turn:
    private void TakeTurn(Cell c){
    Mark curMark = (turn++ % 2 ==0)?Mark.NOUGHT:Mark.CROSS;
    gb.setCell(curMark, c.getRow(), c.getColumn());}
    //Define the following constructor to create the board,
    //provide the event listener, and display the board in
    //the window:
    private TictacToeGUIGame(){
    gb = new Board(3,3,new ActionListener() {


    public void actionPerformed(ActionEvent ae) {
    // TODO Auto-generated method stub
    try{
    Cell c = (Cell) ae.getSource();
    TakeTurn(c);}
    catch (Exception ex){
    }
    }
    });

    this.add(gb);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setTitle("TIC-TAC-TOE");
    this.setSize(300,300);
    this.setVisible(true);
    }
    public static void main(String[] args) {
    // TODO Auto-generated method stub

    SwingUtilities.invokeLater(new Runnable() {


    public void run() {
    // TODO Auto-generated method stub

    new TictacToeGUIGame();

    }
    });
    }

    }
    Last edited by FrenchJavaBean; 01-30-2014 at 10:34 PM.

  2. #2
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: JAR File Help

    1. Put code in code tags
    2. Explain problems
    3. Receive help
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  3. #3
    Join Date
    Dec 2013
    Posts
    16
    Rep Power
    0

    Default Re: JAR File Help

    Quote Originally Posted by zFollette View Post
    1. Put code in code tags
    2. Explain problems
    3. Receive help

    I have a project completed and I can't compile it or make a .JAR file. I have two files that have some errors.


    Board.java



    Board.java:13: error: cannot find symbol
    private Cell[][] cells;
    ^
    symbol: class Cell
    location: class Board
    Board.java:33: error: cannot find symbol
    public void setCell(Mark mark, int row, int column) throws IllegalArgumentException{
    ^
    symbol: class Mark
    location: class Board
    Board.java:44: error: cannot find symbol
    public Cell getCell(int row, int column){
    ^
    symbol: class Cell
    location: class Board
    Board.java:18: error: cannot find symbol
    cells = new Cell[rows][columns];
    ^
    symbol: class Cell
    location: class Board
    Board.java:24: error: cannot find symbol
    cells[r][c] = new Cell(r,c);
    ^
    symbol: class Cell
    location: class Board
    Board.java:35: error: cannot find symbol
    if (cells[row][column].getContent() == Mark.EMPTY)
    ^
    symbol: variable Mark
    location: class Board
    Board.java:56: error: cannot find symbol
    case NOUGHT:
    ^
    symbol: variable NOUGHT
    location: class Board
    Board.java:59: error: cannot find symbol
    case CROSS:
    ^
    symbol: variable CROSS
    location: class Board
    Board.java:62: error: cannot find symbol
    case YELLOW:
    ^
    symbol: variable YELLOW
    location: class Board
    Board.java:65: error: cannot find symbol
    case RED:
    ^
    symbol: variable RED
    location: class Board
    Board.java:68: error: cannot find symbol
    case BLUE:
    ^
    symbol: variable BLUE
    location: class Board
    Board.java:71: error: cannot find symbol
    case GREEN:
    ^
    symbol: variable GREEN
    location: class Board
    Board.java:74: error: cannot find symbol
    case MAGENTA:
    ^
    symbol: variable MAGENTA
    location: class Board
    Board.java:76: error: cannot find symbol
    break; case ORANGE:
    ^
    symbol: variable ORANGE
    location: class Board
    14 errors

    C:\Users\Richard\Documents\NetBeansProjects\TicTac ToeGUIGame\src\games\board>






    Cell.java

    01/24/2014 01:17 PM <DIR> .
    01/24/2014 01:17 PM <DIR> ..
    01/30/2014 06:35 PM 1,843 Board.java
    01/30/2014 07:27 PM 2,871 BoardGameTester.java
    01/30/2014 06:36 PM 1,464 Cell.java
    01/23/2014 02:38 PM 137 Mark.java
    01/23/2014 02:38 PM 103 Outcome.java
    01/23/2014 02:38 PM 65 Player.java
    6 File(s) 6,483 bytes
    2 Dir(s) 1,911,042,834,432 bytes free

    C:\Users\Richard\Documents\NetBeansProjects\TicTac ToeGUIGame\src\games\board>javac Board.java
    Board.java:13: error: cannot find symbol
    private Cell[][] cells;
    ^
    symbol: class Cell
    location: class Board
    Board.java:33: error: cannot find symbol
    public void setCell(Mark mark, int row, int column) throws IllegalArgumentException{
    ^
    symbol: class Mark
    location: class Board
    Board.java:44: error: cannot find symbol
    public Cell getCell(int row, int column){
    ^
    symbol: class Cell
    location: class Board
    Board.java:18: error: cannot find symbol
    cells = new Cell[rows][columns];
    ^
    symbol: class Cell
    location: class Board
    Board.java:24: error: cannot find symbol
    cells[r][c] = new Cell(r,c);
    ^
    symbol: class Cell
    location: class Board
    Board.java:35: error: cannot find symbol
    if (cells[row][column].getContent() == Mark.EMPTY)
    ^
    symbol: variable Mark
    location: class Board
    Board.java:56: error: cannot find symbol
    case NOUGHT:
    ^
    symbol: variable NOUGHT
    location: class Board
    Board.java:59: error: cannot find symbol
    case CROSS:
    ^
    symbol: variable CROSS
    location: class Board
    Board.java:62: error: cannot find symbol
    case YELLOW:
    ^
    symbol: variable YELLOW
    location: class Board
    Board.java:65: error: cannot find symbol
    case RED:
    ^
    symbol: variable RED
    location: class Board
    Board.java:68: error: cannot find symbol
    case BLUE:
    ^
    symbol: variable BLUE
    location: class Board
    Board.java:71: error: cannot find symbol
    case GREEN:
    ^
    symbol: variable GREEN
    location: class Board
    Board.java:74: error: cannot find symbol
    case MAGENTA:
    ^
    symbol: variable MAGENTA
    location: class Board
    Board.java:76: error: cannot find symbol
    break; case ORANGE:
    ^
    symbol: variable ORANGE
    location: class Board
    14 errors

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,410
    Rep Power
    25

    Default Re: JAR File Help

    cannot find symbol
    The compiler can not find the definitions for the symbols that are shown in each error message.
    Make sure all the variable definitions and usages are in scope (within same pair of {}s).
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Join Date
    Dec 2013
    Posts
    16
    Rep Power
    0

    Default Re: JAR File Help

    Hey thanks for your response Norm, I have tried adding the french brackets. Can you show me an example of what you mean? I am not sure how to add the definitions and usages in scope.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,410
    Rep Power
    25

    Default Re: JAR File Help

    Here's sample code showing the scopes of some variables:
    Java Code:
    class A_Class {
       int classVar; // define at class level;  in Scope for all methods
    
       void meth1() {
           int aVar;    // define aVar; in Scope only within meth1
           //  classVar in Scope here
           //...
       } // end meth1()
    
       void meth2() {
           //  aVar in NOT in SCOPE here
           //  classVar in Scope here
           //...
       } //  end meth2()
    } // end class
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Join Date
    Dec 2013
    Posts
    16
    Rep Power
    0

    Default Re: JAR File Help

    Quote Originally Posted by Norm View Post
    Here's sample code showing the scopes of some variables:
    Java Code:
    class A_Class {
       int classVar; // define at class level;  in Scope for all methods
    
       void meth1() {
           int aVar;    // define aVar; in Scope only within meth1
           //  classVar in Scope here
           //...
       } // end meth1()
    
       void meth2() {
           //  aVar in NOT in SCOPE here
           //  classVar in Scope here
           //...
       } //  end meth2()
    } // end class

    Hey

    Thanks for your help I will try to plug away at fixing these errors. I do not know what method I should introduce.


    I get those errors when I try to use javac also when I clean build in NetBeans I get the same errors. I think my class paths must be somewhat ok because I can run my app.

Similar Threads

  1. Replies: 0
    Last Post: 12-31-2013, 05:46 AM
  2. Replies: 1
    Last Post: 07-28-2011, 07:50 PM
  3. Replies: 6
    Last Post: 12-01-2010, 05:31 AM
  4. Replies: 8
    Last Post: 02-18-2010, 12:54 PM
  5. Replies: 0
    Last Post: 02-11-2009, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •