0

so, I've written 3 simple classes in 3 different class files: Point.java, Rectangle.java, Circle.java,

and a main class named main.java. they are all in the same folder name shapes.

the main class just have a main function that declare each of these shapes and print them.

all the files are in this path: ~/Downloads/myProject/src/shapes/

can someone please help me with the specific command i should write to compile this main class?

note that when i use this command: javac -cp src/shapes src/shapes/main.java the compiler returns errors like this:

src/shape/main.java:7: error: cannot find symbol Point p1 = new Point(1.5, 2); ^ symbol: class Point location: class main

for each shape i declared...

2
  • Do you have a package declaration in the classes? Or are they all in the default package? Commented May 6, 2016 at 19:25
  • It may help if you add the source code to reproduce your problem -- head this section of the help pages Commented May 6, 2016 at 19:29

2 Answers 2

0
javac Point.java
javac Rectangle.java
javac Circle.java
javac main.java

Simply compile them in the correct order: Point is used in Rectangle and Circle (I imagine), so compile it before the others.

Remember that in Java class name should always be title case (AKA: Main.java, not main.java).

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

3 Comments

@ThorbjørnRavnAndersen yes, but in which order? You don't know.
Doesn't matter which order.
@LorenzoBarbagli but javac can figure it out.
0

javac option to compile all java files under a given directory recursively

Comments

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.