help

i have put two files in the following directory:

1. d:\temp\packagea\a1.java

2. d:\temp\packageb\a2.java

packagea and packageb are two packages,now i want a2 to use the classes in the a1,but the system always tell me the error:can't analyse symbols

for example:

package packagea;

public class a1{...}

package packageb;

public class a2{

packagea.a1 a=new packagea.a1();

}

i hope someone can tell me what's wrong with my program?

thank you!

[526 byte] By [clsun] at [2007-9-26 12:27:32]
# 1
hi,try following://in class a1import packageb; // in class a2import packagea; regards
swingfreak at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 2
thank you,i will try
clsun at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 3
it seems still wrong with my programwhether my directory is wrong?
clsun at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 4
I think we need to import a package if we want to use a class from that package, like usual import..Max
B_randy at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 5
yes,i have tried that way,but i still can not run my program. :(
clsun at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 6
try thisimport temp.packagea.*;import temp.packageb.*;
contactjaysheel at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 7
forgot to tell u check ur classpath also
contactjaysheel at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 8
how should i set the classpath?
clsun at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 9

the calsspath has to been set to where your class-files are.

with:

SET Classpath=....

another point: it is not enough to import the package you have to import the class too.

import packagea.a1; // or whatever

regards

swingfreak at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 10
hipoint ur classpath to the directory where ur classes are located.in ur case it should be for eg set classpath = d:\temp; %classpath%import packagea.* ;import packageb.* ;this should work..
contactjaysheel at 2007-7-2 3:09:55 > top of Java-index,Archived Forums,Java Programming...
# 11
it seems ok,but i am so sorry to tell you that it still doesn't work:(
clsun at 2007-7-2 3:09:56 > top of Java-index,Archived Forums,Java Programming...
# 12
thank you for all your helpi have settled the problem:)
clsun at 2007-7-2 3:09:56 > top of Java-index,Archived Forums,Java Programming...
# 13
what was the problem?
contactjaysheel at 2007-7-2 3:09:56 > top of Java-index,Archived Forums,Java Programming...
# 14
the compile directory is wrongit should be d:\temp javac packageb\a2.javabut i always do: d:\temp\packageb javac a2.java
clsun at 2007-7-2 3:09:56 > top of Java-index,Archived Forums,Java Programming...