3

I have just written a Java multi-threaded program in Eclipse. It compiled fine and works like a charm.

However, as this is coursework we are required to ensure that it compiles in the command line using 'javac' otherwise we score ZERO!

So, some classes compile others don't. The error I'm getting is the following ( they are all similar just with different class names, this is one example)

GateRunnable.java:7: cannot find symbol
symbol  : class Station
location: class package.name.here.GateRunnable
    public GateRunnable(Station st) {
                        ^

Is this a javac issue? Any help appreciated.

3
  • Get the classpath right. Commented Nov 21, 2012 at 21:32
  • Could you add info about your project package/class structure and how your javac command looks like? Commented Nov 21, 2012 at 21:33
  • In CMD i'm in the src folder and I'm typing : javac GateRunnable.java which gives me the above error, hence I'm trying to compile classes one by one Commented Nov 21, 2012 at 21:38

3 Answers 3

2

Your compile -classpath and/or -sourcepath is incomplete. The compiler doesn't know where to find class Station. Here is a related question that describes how to set the classpath to include all the classes you want.

Sign up to request clarification or add additional context in comments.

2 Comments

If you have circular dependencies (I hope not), you may take a look at the 'sourcepath' option.
Can't get it to work. My current directory is in the src folder where all my classes are. Assuming there are four named Class1.java , Class2.java and so on. How would you set the class/source path to include all of them? Thanks
2

To solve the problem I was having, it was simply necessary to compile all classes by using the following command:

javac *.java 

which compiles all java files in the directory.

Comments

0

have you compiled every .java file in your folder/packages? if not, then do so. Eclipse usually does that for you, but within the terminal it's you taking the responsibility of compiling every part of the code.

2 Comments

...and you need to start compiling your .java files who don't have any dependency on your own java classes before the others. Also, if you use any third party library, don't forget do set the classpath using the -classpath command line option (docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/javac.html).
No, provided it can find the dependencies javac will compile them if they need to be (I do this using javac all day every day for work).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.