• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

How to compile the code on p171?

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 " : " !!
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic