Results 1 to 5 of 5
  1. #1
    rhythmiccycle is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default compile errors (how do I fix)

    I'm trying to complie a tetris game.
    I found a pretty small soruce code here:
    The Tetris game

    I made the three files
    Tetris.java
    Shape.java
    Board.java


    i'm using command line javac to compile

    shape.java complies fine,
    if i put shape.java in a folder called "tetris" and put Tetris.java and Board.java next to the folder, I get a error with this line

    Java Code:
    public Board(Tetris parent) {
    i also get a complier error in tetris.java on the line

    Java Code:
    Board board = new Board(this);
    To me the error seems due to the face board.java and tetris.java both have classes that are refering to one another.

    is there a way to complie two files at once?

    how do I comple???

    I found way more complicated tetris games that I got to work, but I really like the code used on this page, because it not too long and the website breaks it down line by line

    please help?

  2. #2
    user0 is offline Senior Member
    Join Date
    Dec 2010
    Posts
    100
    Rep Power
    0

    Default

    I would try putting all the java files into one folder, i would then compile each java file using javac. After that I would use the java command to run the file that has the main method that starts the game.

    Also note - when you are trying to compile a file name file.java, you use:
    javac file.java

    to run that file you use: java file

    Best,
    --user0--

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    Place the .java files in folders which are named according to their package name (see Managing Packages). Then compile using javac in the root directory (root relative to the package). Alternatively, use an IDE like Eclipse to help manage the packages and just import the files and let the IDE do the dirty work

  4. #4
    rhythmiccycle is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by doWhile View Post
    Place the .java files in folders which are named according to their package name (see Managing Packages). Then compile using javac in the root directory (root relative to the package).
    thanks that link was helpful

    all the files start with
    Java Code:
    package tetris;
    so i put them in a folder called "tetris" then in the terminal I cd-ed to the parent folder of tetris and ran:

    javac tetris/Tetris.java


    summary
    Java Code:
    mike@mike-desktop:~/workspace/tetris$ ls
    Board.java  Shape.java  Tetris.java
    mike@mike-desktop:~/workspace/tetris$ cd ..
    mike@mike-desktop:~/workspace$ javac tetris/Tetris.java 
    mike@mike-desktop:~/workspace$ ls tetris/
    Board.class  Board$TAdapter.class  Shape.java               Tetris.class
    Board.java   Shape.class           Shape$Tetrominoes.class  Tetris.java

    so I finally got it to compile!

    now I need to figure out how to run it.

  5. #5
    rhythmiccycle is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    its running, i'm happy!!

    thanks alot doWhile

    Java Code:
    $ java tetris/Tetris

Similar Threads

  1. Compile Errors and need to add a second static
    By lk1001 in forum New To Java
    Replies: 5
    Last Post: 03-04-2010, 11:58 PM
  2. Replies: 12
    Last Post: 01-17-2010, 11:05 PM
  3. compile ignoring dependency errors
    By Geoffrey in forum Java Servlet
    Replies: 1
    Last Post: 09-10-2009, 06:45 PM
  4. Help with Compile time errors
    By bri1547 in forum New To Java
    Replies: 2
    Last Post: 08-24-2008, 11:22 PM

Posting Permissions

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