This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot find symbol  RSS feed

 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Directory Structure: foo/test/xcom/x1com/x2com
B.java is in xcom and A.class is in x2com

foo
test
xcom
B.java
x1com
x2com
A.class



I am trying to compile classB, but could not find A.class

Following are my failed attempts in Windows

C:\javac\foo\test\xcom\x1com>javac -classpath . C:\javac\foo\test\xcom\B.java
C:\javac\foo\test\xcom\B.java:2: cannot find symbol
symbol: class A
public class B extends A{}
^
1 error

C:\javac\foo\test\xcom\x1com\x2com>javac -classpath . C:\javac\foo\test\xcom\B.java
C:\javac\foo\test\xcom\B.java:2: cannot find symbol
symbol: class A
public class B extends A{}
^
1 error


C:\javac\foo\test>javac -classpath . C:\javac\foo\test\xcom\B.java
C:\javac\foo\test\xcom\B.java:2: cannot find symbol
symbol: class A
public class B extends A{}
^
1 error

C:\javac\foo\test>javac C:\javac\foo\test\xcom\B.java
C:\javac\foo\test\xcom\B.java:2: cannot find symbol
symbol: class A
public class B extends A{}
^
1 error


C:\javac\foo\test>javac -classpath .;C:\javac\foo\test C:\javac\foo\test\xcom\B.java
C:\javac\foo\test\xcom\B.java:2: cannot find symbol
symbol: class A
public class B extends A{}
^
1 error

 
Henry Wong
author
Sheriff
Posts: 22827
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First, in class B, you need to import A.

Second, compile like this...

C:\javac\foo\test>javac -classpath . xcom\B.java

Henry
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically I forgot to import it.

Just to add..even the following statement will work.

C:\javac\foo\test>javac xcom\B.java

So I understand, while searching .class file javac will search by appending the package structure from the current directory (here it appends xcom\x1com\x2com), but to search for .java files it has to put the path explicitly while searching.

Thanks Henry.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!