java找不到符号 类,编译包含其他类类型对象的Java类时找不到符号错误

I have a java package which contains two classes. Class A and Class B. I need to create an object of A type in class B. I don't know what is happening. Please someone help me out.

package pack;

class A

class B

I'm using JDK1.5 and tomcat and placed them in java folder in my D drive.

D:\java\jdk1.5

D:\java\tomcat

Right now, my package folder is also in above location

D:\java\pack

Below is how i am compiling my java class files.

Step 1: Compiling A.java

D:\Java\pack>set path=D:\java\jdk1.5\bin (setting up path for jdk1.5 compiler)

D:\Java\pack>javac A.java (Successfuly compiled and formed A.class)

Step 1: Compiling B.java

D:\Java\pack>javac B.java (here, i get an error message )

Below is the ERROR message

Error Message

D:\Java\pack>javac B.java

B.java:9: cannot find symbol

symbol : class A

location: class pack.B

A a = new A(); //creating an object of A type

^

B.java:9: cannot find symbol

symbol : class A

location: class pack.B

A a = new A(); //creating an object of A type

^

2 errors

解决方案

javac pack\A.java pack\B.java

will do the trick. The compiler has to be able to resolve everything in one invocation. If it's looking for

pack.B

then that corresponds to

pack\B.java

in the directory structure

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值