wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes classpath setting rightly. But strange problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "classpath setting rightly. But strange problem" Watch "classpath setting rightly. But strange problem" New topic
Author

classpath setting rightly. But strange problem

babu hiran
Greenhorn

Joined: Jun 04, 2005
Posts: 12
i have my java files in the below directory and i wanted my class files to be generated in the same directory
C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\coreservlets

i need to compile 3 files in the above path which are namely
Primes.java
PrimeList.java
PrimeNumbers.java
The relation between them is like this
PrimeNumbers.java (needs) PrimeList.java (needs) Primes.java

The following is the way i am doing it.

C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\coreservlet>set CLASS
PATH=%CLASSPATH%;C:\jakarta-tomcat-4.1.31\webapps\examples\

C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\coreservlets>javac Pri
mes.java

C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\coreservlets>javac Pri
meList.java
PrimeList.java:45: cannot resolve symbol
symbol : variable Primes
location: class coreservlets.PrimeList
BigInteger start = Primes.random(numDigits);
^
PrimeList.java:47: cannot resolve symbol
symbol : variable Primes
location: class coreservlets.PrimeList
start = Primes.nextPrime(start);
^
2 errors

I hope setting classpath is done right way and this PrimeList.java which needs Primes.java should be able to identify Primes.class. But i wonder what could be the problem.
[ August 24, 2005: Message edited by: narayana babu reddyvari ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9052
    
  12
Your classpath needs to point to the directory that contains the classes. You said your classes should be in
C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\coreservlets
but your classpath points to
C:\jakarta-tomcat-4.1.31\webapps\examples\

Unless Primes.java, PrimeList.java, and PrimeNumbers.java are in a package named coreservlets, in which case the classpath should point to
C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\
and you should compile using
C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes>javac coreservlets\Primes.java
etc.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
prashant fusate
Greenhorn

Joined: Aug 24, 2005
Posts: 16
Hi,
if you are using eclips as a editor for java then no need to worry there is a option so that you can set output directory.your java file after compilation stoard in output directory. so no need to set class path everytime.
in eclips you need to create new project give him source directory and output directory
it takes java file from source directory and compiled it ,after compilation it stored in output directory werever you set the output dir.

for the detail infromation you can search for eclips site
[ August 25, 2005: Message edited by: prashant fusate ]

psfusate
babu hiran
Greenhorn

Joined: Jun 04, 2005
Posts: 12
Marilyn de Queiroz
-------------------
i did it as told by u and it started working. Thank you so much.
But i have a doubt. some time back when i set class path to a directory and compile java files in its child directory, it was able to identify other classes in diff files that it is refering to in the same dirctory. so big confusion about what are the possible ways of doing it.

prashant
-----------
As u said i have actually used borland jbuilder which doesnt need all these classpath issues.
[ August 25, 2005: Message edited by: narayana babu reddyvari ]
 
 
subject: classpath setting rightly. But strange problem