• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problems compiling packages #2 with JSP

 
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still have a problem on page 85 of Head First Servlets and JSP that I have not been able to figure out.

I can't help myself because I don�t fully understand the two class paths in the line.

javac -classpath "C:\Program Files\ApacheSoftwareFoundation\Tomcat\common\lib\servlet-api.jar:". -d classes src/com/examples/web/BeerSelect.java


Here is my what I have, and result

servlet-api at
C:\Program Files\ApacheSoftwareFoundation\Tomcat\common\lib\servlet-api.jar

model class at
C:\java\JSPHFprojects\beerV1\src\com\example\model\BeerExpert.java



servlet at
C:\java\JSPHFprojects\beerV1\src\com\example\web\ BeerSelect.java



Result is



any help much appreciated
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-d tells javac which directory to put teh generated classes into, you are telling it the directory is src/com/examples/web/BeerSelect.java, and javac is telling you there is no such directory.

if you type javac on the command line it will list out it options.

G
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I now understand that the -d tells compiler where to put the generated file, but doesn't compiler create the path if it does not exist?

What the result is saying, is that the compiler can't find the source file which is in

C:\java\JSPHFprojects\beerV1\src\com\example\web\BeerSelect.java

when calling the compiler using

C:\java\JSPHFprojects\beerV1>javac -classpath "C:\Program F ... servlet-api.jar:". -d classes src/com/examples/web/BeerSelect.java
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats a good point.
You need to use the -sourcepath option to tell javac where to find the soruce.

(i think)

G
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But
javac -classpath "C:\Program Files\ApacheSoftwareFoundation\Tomcat\common\lib\servlet-api.jar:". -d classes -sourcepath . src/com/examples/web/BeerSelect.java

and some variations, doesn't work either...
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try:


The Colon and . at the end of the classpath look wrong, perhaps it should be a semi colon between the " and the .

i.e.


Other then that I am not sure. I dont have the book to hand to try it myself.

G
[ June 18, 2007: Message edited by: Gavin Tranter ]
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Gavin, but still no luck



will try again tomorrow

[ June 18, 2007: Message edited by: marten kay ]
[ June 18, 2007: Message edited by: marten kay ]
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are your java files actual in:

src/com/examples/web/

and is src a sub directory of your current directory?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change the : to a ;
i.e.
javac -classpath "C:\Program Files\ApacheSoftwareFoundation\Tomcat\common\lib\servlet-api.jar;."

The : is used as a separator on unix/linux, but on Windows you need to change it to ;
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much

the semi colon did the job

I also found a good resource javac arguments for window

Joanne, you are a star, tomorrow I will be able to turn the page to p86
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the exactly same problem.
For me,
model@
D:\MyProjects\beerV1\src\com\example\model\BeerExpert.java
servlet@
D:\MyProjects\beerV1\src\com\example\web\BeerSelect.java
servlet-api@
C:\Tomcat\apache-tomcat-5.5.23\common\lib\servlet-api.jar
Now I am trying to compile using:
javac -classpath "C:\Tomcat\apache-tomcat-5.5.23\common\lib\servlet-api.jar;". -d classes -sourcepath src/com/examples/web/BeerSelect.java

Still it is not getting compiled giving the following error:

javac: no source files
Usage: javac <options> <source files>
use -help for a list of possible options

Please help.
Also I don't know the usage of . after "c:\Tomcat...\servlet-api.jar;"

~ Veeru
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic