Results 1 to 5 of 5
  1. #1
    danbwater is offline Member
    Join Date
    Oct 2013
    Location
    Arkansas
    Posts
    10
    Rep Power
    0

    Default Error: Could not find or load main class Games.Board.TicTocToeGUIGame

    Upon running this I receive the following error...Error: Could not find or load main class Games.Board.TicTocToeGUIGame Would you please help me figure out what is wrong?
    Here is the code

    Main

    Java Code:
    package Games.Board;
    
    
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    
    public class TicTocToeGUIGame {	
    	private static final String EXITONCLOSE = null; 
    	public static void main(String[] args) {
    	
    	SwingUtilities.invokeLater( new Runnable () {
    			public void run() { Games.Board.TicTacToeGUlGame ticTacToeGUlGame = new TicTacToeGUlGame(); }
    	
    	private Board gb; 
    	private int turn;
    	private void takeTurn(Cell c) {
    	Mark curMark = (turn++ 1 2 == 0)? Mark.NOUGHT: Mark.CROSS;
    	gb.setCell(curMark, c.getRow(), c.getColumn());
    	}
    	private void TicTacToeGUlGame() {
    		gb = new Board(3, 3);
    		this.add(gb);
    		this.setDefaultCloseOperation(EXITONCLOSE); this.setTitle("TIC-TAC-TOE");
    		this.setSize(300, 300); this.setTitle(true);
    }
    	private void setTitle(boolean b) {
    		// TODO Auto-generated method stub
    		
    	}
    	private void setSize(int i, int j) {
    		// TODO Auto-generated method stub
    		
    	}
    	private void setDefaultCloseOperation(String exitonclose2) {
    		// TODO Auto-generated method stub
    		
    	}
    	private void setTitle(String string) {
    		// TODO Auto-generated method stub
    		
    	}
    	private void add(Board gb2) {
    		// TODO Auto-generated method stub
    		
    	}
    	
    	class TicTocToeGUIGame extends JFrame});
    	
    }
    	}
    Board

    Java Code:
    package Games.Board;
     
    import java.awt.GridLayout;
    import java.awt.event.ActionListener;
    import javax.swing.JPanel;
     
    
    public class Board extends JPanel {
    /**
         *
         */
        private static final long serialVersionUID = 1L;
            private Cell[][] cells;
    public Board(int rows, int columns) {
    cells = new Cell[rows][columns];
    for( int r = 0; r < cells.length; r++ ) {
    for (int c = 0; c < cells[r].length; c++) {
    cells[r][c] = new Cell(r,c);
    }
    }
    }
    int[] ints = new int[3];
     
    public void  getOutOfBoundEx() {
     
    ints[2] = 16;
    ints[3] = 17; //THIS WILL CAUSE THE ERROR as element [3] doesnt not exist
     
    }
    public Board(int rows, int columns, ActionListener ah) {
        cells = new Cell[rows][columns];
        this.setLayout(new GridLayout());
        for( int r = 0; r < cells.length; r++ ) {
        for (int c = 0; c < cells[r].length; c++) {
        cells[r][c] = new Cell(r,c);
        this.add(cells[r][c]);
        cells[r][c].addActionListener(ah);
        }
        }
        }
    private void add(Cell cell) {
        // TODO Auto-generated method stub
         
    }
    public void setCell(Mark mark, int row, int column) throws
    IllegalArgumentException {
    if (cells[row][column].getContent() == Mark.EMPTY)
    cells[row][column].setContent(mark);
    else throw new IllegalArgumentException("Player already there!");
    }
    public Cell getCell(int row, int column) {
    return cells[row][column];
    }
            @Override
            public String toString() {
    StringBuilder str = new StringBuilder();
                for (Cell[] cell : cells) {
                    str.append("|");
        for (Cell cell1 : cell) {
            switch (cell1.getContent()) {
                case NOUGHT:
                    str.append("O");
                    break;
            case CROSS:
                str.append("X");
                break;
            case YELLOW:
                str.append("Y");
                break;
            case RED:
                str.append("R");
                break;
            case BLUE:
                str.append("B");
                break;
            case GREEN:
                str.append("G");
                break;
            case MAGENTA:
                str.append("M");
                break;
            case ORANGE:
                str.append("M");
                break;
            default: //Empty
                str.append("");
            }
            str.append("|");
        }
                    str.append("\n");
                }
        return str.toString();
     
    }
     
    }
    Cell

    Java Code:
    package Games.Board;
    
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.event.ActionListener;
    
    public class Cell {private Mark content;
    private final int row, column;
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    
    	}
    
    public Cell(int row, int column) { 
    	this.row = row;
        this.column = column; 
    content = Mark.EMPTY;
    }
    public Mark getContent() { return content; }
    
    public void setContent(Mark content) { this.content = content; } 
    public int getRow() { return row; }
    public int getColumn() { return column; }
    
    public void addActionListener(ActionListener ah) {
    	// TODO Auto-generated method stub
    	
    }
    public void paintComponent(Graphics g) {
    	//paint the basic button first
    	super.paintComponent(g);
    	int offset = 5;
    	Graphics2D g2 = (Graphics2D) g;
    	g2.setStroke(new BasicStroke(5));
    	switch(content) {
    	case NOUGHT:
    	g2.setColor(Color.RED);
    	//Draw 0
    	g2.drawOval(offset, offset, this.getWidth() - offset * 2, this.getHeight() - offset * 2);
    	break;
    	case CROSS:
    	g2.setColor(Color.BLACK);
    	//Draw X
    	g2.drawLine(offset, offset, this.getWidth() - offset , this.getHeight() - offset);
    			g2.drawLine(this.getWidth() - offset, offset , offset, this.getHeight()- offset); 
    	break;
    	default:
    		break;
    			}
    }
    
    private int getWidth() {
    	// TODO Auto-generated method stub
    	return 0;
    }
    
    private int getHeight() {
    	// TODO Auto-generated method stub
    	return 0;
    }
    }
    Thanks for your time and effort. Danny

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: Error: Could not find or load main class Games.Board.TicTocToeGUIGame

    .Error: Could not find or load main class Games.Board.TicTocToeGUIGame
    What program are you executing that gives that error? What is the command line you used
    and what was the current directory when the command was executed?
    Where were the class files for the program?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    danbwater is offline Member
    Join Date
    Oct 2013
    Location
    Arkansas
    Posts
    10
    Rep Power
    0

    Default Re: Error: Could not find or load main class Games.Board.TicTocToeGUIGame

    I am using eclipse, the main was open, and I clicked on the run button in eclipse and received this error ... Error: Could not find or load main class Games.Board.TicTocToeGUIGame

  4. #4
    danbwater is offline Member
    Join Date
    Oct 2013
    Location
    Arkansas
    Posts
    10
    Rep Power
    0

    Default Re: Error: Could not find or load main class Games.Board.TicTocToeGUIGame

    When I run it now I receive this error....
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    The left-hand side of an assignment must be a variable
    Syntax error on token "1", invalid AssignmentOperator
    The nested type TicTocToeGUIGame cannot hide an enclosing type
    Syntax error, insert "ClassBody" to complete ClassDeclaration

    at Games.Board.TicTocToeGUIGame.main(TicTocToeGUIGame .java:17)

    Thanks for your time Danny

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: Error: Could not find or load main class Games.Board.TicTocToeGUIGame

    Try getting error messages from the compiler that shows what the problem is. IDEs often hide and use their own names for errors that the javac compiler clearly shows and explains.

    Here is a sample javac error message:
    The message should show the source with a ^ under the location of the error.
    Here is a sample from the javac compiler:
    Java Code:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Error: Could not find or load main class
    By iSamir in forum New To Java
    Replies: 16
    Last Post: 06-25-2013, 06:39 AM
  2. Error:Could Not Find or Load Main Class
    By vickyv200 in forum New To Java
    Replies: 3
    Last Post: 08-29-2012, 02:10 AM
  3. Error: could not find or load main class
    By sloppygecko in forum New To Java
    Replies: 3
    Last Post: 08-08-2012, 04:11 PM
  4. Error: Could not find or load main class
    By Tybald in forum Eclipse
    Replies: 5
    Last Post: 05-28-2012, 12:22 PM
  5. Error: Could not find or load main class
    By ITSlave in forum New To Java
    Replies: 4
    Last Post: 09-15-2011, 10:47 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
  •