当前位置: 技术问答>java相关
关于java的包的问题。
来源: 互联网 发布时间:2015-09-27
本文导语: 我找了三个java程序,代码里声明都是在package hall里。我于是作了一个文件夹hall,把程序都放在里面。但当编译PrimeList.java时却说找不到同一目录下的Primes.class.情况如下: E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclassesh...
我找了三个java程序,代码里声明都是在package hall里。我于是作了一个文件夹hall,把程序都放在里面。但当编译PrimeList.java时却说找不到同一目录下的Primes.class.情况如下:
E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclasseshall>dir
Volume in drive E is DATA
Volume Serial Number is 10ED-0E11
Directory of E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclassesh
all
2002/09/29 16:32 .
2002/09/29 16:32 ..
2002/09/29 16:33 1,384 SearchSpec.java
2002/09/29 17:23 1,263 SearchSpec.class
2002/09/29 17:22 2,402 SearchEngines.java.bak
2002/09/29 17:23 3,500 SearchEngines.java
2002/09/29 17:23 1,335 SearchEngines.class
2002/10/09 10:29 1,113 NumberedPrimes.java
2002/10/09 10:35 1,723 PrimeList.java.bak
2002/10/09 11:01 2,312 Primes.java
2002/10/09 11:15 2,095 Primes.class
2002/10/09 11:21 1,733 PrimeList.java
10 File(s) 18,860 bytes
2 Dir(s) 382,296,064 bytes free
E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclasseshall>javac Prim
eList.java
PrimeList.java:40: cannot resolve symbol
symbol : variable Primes
location: class hall.PrimeList
BigInteger start = Primes.random(numDigits);
^
PrimeList.java:42: cannot resolve symbol
symbol : variable Primes
location: class hall.PrimeList
start = Primes.nextPrime(start);
^
2 errors
CLASSPATH如下:
.;E:lxJAVAjdk131libdt.jar;E:lxJAVAjdk131libtools.jar;E:wwwtomcatjakarta-tomcat-4.0-b1binservlet.jar
请各位赐教!
E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclasseshall>dir
Volume in drive E is DATA
Volume Serial Number is 10ED-0E11
Directory of E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclassesh
all
2002/09/29 16:32 .
2002/09/29 16:32 ..
2002/09/29 16:33 1,384 SearchSpec.java
2002/09/29 17:23 1,263 SearchSpec.class
2002/09/29 17:22 2,402 SearchEngines.java.bak
2002/09/29 17:23 3,500 SearchEngines.java
2002/09/29 17:23 1,335 SearchEngines.class
2002/10/09 10:29 1,113 NumberedPrimes.java
2002/10/09 10:35 1,723 PrimeList.java.bak
2002/10/09 11:01 2,312 Primes.java
2002/10/09 11:15 2,095 Primes.class
2002/10/09 11:21 1,733 PrimeList.java
10 File(s) 18,860 bytes
2 Dir(s) 382,296,064 bytes free
E:wwwtomcatjakarta-tomcat-4.0-b1webappsROOTWEB-INFclasseshall>javac Prim
eList.java
PrimeList.java:40: cannot resolve symbol
symbol : variable Primes
location: class hall.PrimeList
BigInteger start = Primes.random(numDigits);
^
PrimeList.java:42: cannot resolve symbol
symbol : variable Primes
location: class hall.PrimeList
start = Primes.nextPrime(start);
^
2 errors
CLASSPATH如下:
.;E:lxJAVAjdk131libdt.jar;E:lxJAVAjdk131libtools.jar;E:wwwtomcatjakarta-tomcat-4.0-b1binservlet.jar
请各位赐教!
|
alphazhao(绿色咖啡) 的说法当然不对
只有在那些class没有使用package的时候才成立
这里使用了package,需按我上面讲的做
(哎,这些都是基本的东西)