wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Problems compiling packages #2 with JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problems compiling packages #2 with JSP" Watch "Problems compiling packages #2 with JSP" New topic
Author

Problems compiling packages #2 with JSP

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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


when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
-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 kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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

Joined: Jan 01, 2007
Posts: 333
Thats a good point.
You need to use the -sourcepath option to tell javac where to find the soruce.

(i think)

G
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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

Joined: Jan 01, 2007
Posts: 333
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 kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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

Joined: Jan 01, 2007
Posts: 333
Are your java files actual in:

src/com/examples/web/

and is src a sub directory of your current directory?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3415
    
  12
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 ;


Joanne
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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
Veeru Bond
Greenhorn

Joined: Aug 09, 2007
Posts: 9
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


Mission SCWCD!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems compiling packages #2 with JSP
 
Similar Threads
servlet compiling errors
weird problem
can't import own model
Problem in accessing model in diffeerent package(Servlet-HFS)
Need a few JSP tips