Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to compile the code on p171?

 
prajal Mehta
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
This is just a classpath question.
Let me know if I should move it to some other forum.

how do we specify 2 or more classpaths?
I am assuming it is using " : " !!
am I wrong?


I am not able to compile the MyServletContextListener.java programs on page 171 in HF book.

I have following directory structure-

C:\MyProjects\beerV1\src\com\example\Dog.java and
C:\MyProjects\beerV1\src\com\example\MyServletContextListener.java

and for storing class files I have

C:\MyProjects\beerV1\classes\com\example

I could compile Dog.java without any problem.
But when I try to compile MyServletContextListener.java I am getting lot of errors. For learning java, I have used Eclipse tool, so I am little weak when it comes to command line options for compiling and executing programs.
MyServletContextListener.java had code something like this


I am using following command to compile MyServletContextListener


It gives 7 errors such as "could not find symbol- class ServletContextListener", "could not find symbol- class Dog"

Strange thing is if I give only
C:\MyProjects>javac -classpath "C:\Program Files\apache tomcat\apache-tomcat-5.5.25\common\lib\servlet-api.jar" -d beerV1\classes beerV1\src\com\example\MyServletContextListener.java

I get only "could not find symbol- class Dog" error.

So may be I am using the -classpath option incorrectly?
how do we specify 2 or more classpaths?
I assumed it is using " : " !!
 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to use ; to seperate more than one classpath....
one more thing...you are just setting the path to servlet-api.jar file and what about your dog.class file.
It is located some where in C drive and you are not setting that path.Include that path also.
 
prajal Mehta
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey swapna ..thanks for the reply.
I was using : to separate class paths because that's what I read in SCJP Study Guide by K And B
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was using : to separate class paths because that's what I read in SCJP Study Guide by K And B

Colons are used on Unix. You'll have to use semi-colons on Windows.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic