0

I know this question has been asked and answered a number of times. But I somehow am not able to get this right. I have a package having the following structure

model/
   InputDetails.java
   RelationDetails.java

Now the file RelationDetails has the following structure:

package model;
public class RelationDetails {
     ....
}

And the file InputDetails has the following structure

package model;
public class InputDetails {
    .....
}

Now I have compiled the RelationDetails.java file that creates a RelationDetails.class file in the same directory. But when I try to compile the InputDetails.java file, It shows the error

Symbol not found

wherever RelationDetails has been used. Where am I going wrong??

6
  • Where am I going wrong?? You need to go deeper... Commented Nov 7, 2013 at 14:22
  • 4
    Please tell us which command you executed and from which directory. Commented Nov 7, 2013 at 14:24
  • Please give more details and elaborate the error "Symbol Not Found" Commented Nov 7, 2013 at 14:24
  • provide details how the InputDetails is referencing the other Commented Nov 7, 2013 at 14:30
  • go to the current directory and execute > javac *.java Commented Nov 7, 2013 at 14:35

4 Answers 4

4

I'd recommend using an IDE like Eclipse or IntelliJ IDEA. They will do the compiling for you. Or use Ant, Gradle or Maven to compile. I am a professional Java developer and I cannot remember the last time I used javac from the command line. There's no need for it.

If you insist on using javac directly, either compile both files together from the appropriate source folder (the directory above "model").:

javac "model/InputDetails.java" "model/RelationDetails.java"

Or, if you want to compile them separately:

javac -classpath . "model/InputDetails.java"
javac -classpath . "model/RelationDetails.java"

The -classpath . bit adds the current folder to the classpath for the javac executable, so it can find the previously compiled class and you won't get the 'Symbol not found' errors.

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

1 Comment

Yes!! This did the job..Thanks..:)
0
$ pwd
/tmp/model

$ ls
InputDetails.java  RelationDetails.java

$ javac  InputDetails.java  RelationDetails.java

$ ls *.class
InputDetails.class  RelationDetails.class

2 Comments

From which directory? Rather than rushing to post an answer, why not wait and see what the OP did wrong and correct them?
Ok, now your answer may be of some use to the OP.
0

I am just tried in my eclipse nothing will be showing errors, better to user Eclipse or STS they will help you like this problems easily I think so..

Comments

-1

compile with fully qualifier name.

javac model\YourClass.java

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.