0

I made a project (Chess GUI game) that includes a few directories, in java. Here is the project tree:

├───images
│       black_bishop.png
│       black_king.png
│       black_knight.png
│       black_pawn.png
│       black_queen.png
│       black_rook.png
│       white_bishop.png
│       white_king.png
│       white_knight.png
│       white_pawn.png
│       white_queen.png
│       white_rook.png
│
└───source
    ├───GameGUI
    │       ChessBoardPanel.java
    │       ChessCellPanel.java
    │       Game.java
    │       PieceLabel.java
    │
    ├───MainComponents
    │       Board.java
    │       Cell.java
    │       Move.java
    │       Piece.java
    │
    └───Pieces
            Bishop.java
            King.java
            Knight.java
            Pawn.java
            Queen.java
            Rook.java

When trying to compile the file with the main method, which is Game.java, I go to the directory (in cmd using cd), and use javac Game.java.

But it doesn't compile and shows the following error:

source\GameGUI\Game.java:18: error: cannot find symbol
                frame.add(new ChessBoardPanel());
                              ^
  symbol: class ChessBoardPanel
1 error

I suppose it's because I have to compile the ChessBoardPanel.java file as well. But then I would have to compile all the files with the classes it's using, recursively.

I can do it by hand I guess, but my question is, is there a faster way? I just haven't tried to compile it and run manually since I was using vscode's extension to run it directly.

Im asking this because I want to upload it to GitHub and add instructions on how to run it without assuming that the viewer has vscode installed.

nortain32
  • 69
  • 1
  • 7
  • "But then I would have to compile all the files with the classes it's using, recursively." indeed – Stultuske Jun 21 '23 at 12:41
  • *Im asking this because I want to upload it to GitHub and add instructions on how to run it without assuming that the viewer has vscode installed.* You should be using Maven or Gradle – g00se Jun 21 '23 at 13:13
  • I see. Never did such a thing before... can you refer me to an article or a good tutorial on how to compile and run java projects using Gradle or Maven? – nortain32 Jun 21 '23 at 13:25
  • And build it locally, providing a jar distro (perhaps with a runner script). – Dave Newton Jun 21 '23 at 13:25
  • The maven and Gradle docs should be sufficient to get started. – Dave Newton Jun 21 '23 at 13:26
  • Yes, and when you've looked at the Maven docs, [here](https://technojeeves.com/tech/maven-chess-project.zip) is your project as Maven. All you need to do is replace the dummy files with your own and it will compile and run for you. Package names, should all be lower case, but I've left in your originals – g00se Jun 21 '23 at 13:29
  • @g00se, one more question - is there any way to integrate maven into my existing project without creating a new one with maven and copying the source file in there? Since i've already uploaded the project to github – nortain32 Jun 21 '23 at 13:55
  • As long as your keep the right paths, but tbh, it's better to keep a working project and build a new one alongside rather than risk wrecking something that already works. VS Code says it import Maven projects without issue, but if you put the github link up, I'll help put your code into the Maven skeleton – g00se Jun 21 '23 at 13:57

0 Answers0