Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not able to set environment variables, HFSJ- beer example

 
Monica negi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
refernce with HF servlets JSP Beer example
Howdy!!
This is weird


when I am using this command line to complile 3rd servlet version, it's coming up fine

C:\Mon\javu\MyProject\beerV1> javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;classes;." -d classes src\com\example\web\BeerSelect.java

but I am not able to set the variables in environment variables in system settings

please let me know what should I set in system variables corresponding to the above given command.

-thanks
Monica
 
Swathi Kota
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set this classpath in your system settings.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar
Then you need not set classpath everytime for compilation.
 
Monica negi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Swathi..
I tried that, but is not working..
 
Giovanni De Stefano
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Monica,

how are you setting the CLASSPATH in your system?

Are you using Windows or Linux?
 
Monica negi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
windows
 
Monica negi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is happening only when a class is trying to find any other class in other package ....error is
--package.com.example.beer does not exist

but it is not happening when I am directly giving the claspath in the command line

C:\Mon\javu\MyProject\beerV1> javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;classes;." -d classes src\c
m\example\web\BeerSelect.java
 
sameer khazi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All...Hi Monica. Even i too have encountered the same issue which you have stated in your post.

But what Ms . Swati has give a solution , i have set the classpath much before,even then i am getting the same error as Monica has described in her post.

Any other alternative please let me too know that.

thank you
 
Giovanni De Stefano
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Monica,

please refer to Head First Servlet & JSP 1st Edition, page 82.

1) cd beerV1
2) javac -classpath "your tomcat servlet-api.jar path:classes:." -d classes src/com/example/model/BeerExpert.java

Please note that BeerSelect.java depends on BeerExpert.java thus you have to compile it first and then

3) javac -classpath "your tomcat servlet-api.jar path:classes:." -d classes src/com/example/web/BeerSelect.java

Let me know if this works...

Giovanni
[ September 16, 2008: Message edited by: Giovanni De Stefano ]
 
Monica negi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for all your help Givonnai

here is the story..
1> I did
C:\>echo %catalina_home%
I got
C:\Program Files\Apache Software Foundation\Tomcat 5.5

I checked entry of catalina_home in environment variables
there it was exactly same - C:\Program Files\Apache Software Foundation\Tomcat 5.5


2> I did
C:\>echo %classpath%
I got
;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar(missing ;classes;. in the end)

I checked in enviroment variables
I got it same
-;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar
(although my memory is keeping telling me- sweey you did set it up with ;classes;.)

3> I changed classpath in the environment variables and tried to compile with

C:\Mon\javu\MyProject\beerV1\src\com\example\web>javac BeerSelect.java

Got the same error again - class not found

4> I tried again to compile it from the directory this time

C:\Mon\javu\MyProject\beerV1>javac -d classes src\com\example\web\BeerSelect.java


Class compliled successfully.


Thanks a lot all of you guys, especially Givonnai

One last question - I have seen in other forums that people suggesting classpath of both - your development diectory and your deployment directory should be there in your environment variables, do we need to give the path of development directory also in the classpath with a ; in between.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic