简体   繁体   中英

(Java) “error: cannot find symbol” when compiling?

This is the first time I'm coding in Linux, I'm used with writing in Windows. So my problem: I have a map called Train , in there I have two classes: Train.java and Lab1.java .

When I try to compile(using javac Train.java in the terminal), I get no errors with one of the class, but with the other one I get this error:

Lab1.java:58: error: cannot find symbol
        Train trainThread2 = new Train(tsi, trackSemas, secondTSpeed, 2, true, tsispeed,8);

This code is from the Lab1.java class. It points at the Train and shows this error above, that it cannot find the symbol Train

I didn't find any information that helped me, so I'll try asking here.

Lab1 depends on the class Train so you need to tell the path of the compiled Train class in its classpath. The easiest solution is to compile both at once:

javac Train.java Lab1.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM