-1

I've tried to find a solution to my the compile error it works when ran in eclipse but not if i try to compile it in the terminal..

Here are the two classes I've started to write

load.java

package doom;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;

public class load {

    public int row;
    public int columns;
    private char[][] world;

    public load() throws IOException{
        BufferedReader file01 = new BufferedReader(new FileReader("map1.txt"));
        int rows = 0;
        while((file01.readLine()) != null){
            rows++;
        }
        world = new char[rows][];
    }

    public void getMap() throws IOException{
        BufferedReader file01 = new BufferedReader(new FileReader("map1.txt"));
        String line;
        int i = 0;
        while((line=file01.readLine()) != null){
            world[i++] = line.toCharArray();
        }
        System.out.println(Arrays.deepToString(world));
        System.out.println(world[4][6]);
        file01.close();
    }


}

start.java

package doom;

import java.io.IOException;

public class start {

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        load world = new load();
        world.getMap();
    }

}

Here's the error I am getting when trying to compile in terminal.

138-38-157-112:tet ciaranashton$ javac start.java
start.java:9: error: cannot find symbol
        load world = new load();
        ^
  symbol:   class load
  location: class start
start.java:9: error: cannot find symbol
        load world = new load();
                         ^
  symbol:   class load
  location: class start
2 errors
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
user202051
  • 173
  • 2
  • 5
  • 17
  • 2
    compile load.java first. and you are good to go. – codingenious Feb 14 '14 at 20:59
  • 1
    just a note, class names should start with a capital letter. – turbo Feb 14 '14 at 21:03
  • 1
    Its bad to name classes lowercase. You must use MyClass not myClass. – Smertokogt Feb 14 '14 at 21:07
  • 1
    You're only compiling one class; how do you suppose that would work? `javac load.java start.java` (And as mentioned, please use proper naming conventions) – Brian Roach Feb 14 '14 at 21:08
  • Dup: [How to compile multiple java source files in command line](http://stackoverflow.com/questions/4800781/how-to-compile-multiple-java-source-files-in-command-line) – Brian Roach Feb 14 '14 at 21:09
  • I changed my class names and the compile worked but getting a different error now. No Class Def Found. Ive edited the question. Thank you all and for the link @BrianRoach – user202051 Feb 14 '14 at 21:29
  • @user20205 - Editing a question in a way that totally changes its meaning (like you did) is frowned on. In future, ask a new question. – Stephen C Feb 25 '17 at 02:18

1 Answers1

0

You need to have load.class file, because start.java is referring to load.java.

Just compile load.java first, and your program will work.

codingenious
  • 8,385
  • 12
  • 60
  • 90