GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes not able to set environment variables, HFSJ- beer example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "not able to set environment variables, HFSJ- beer example" Watch "not able to set environment variables, HFSJ- beer example" New topic
Author

not able to set environment variables, HFSJ- beer example

Monica negi
Greenhorn

Joined: Sep 15, 2008
Posts: 6
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

Joined: Jun 04, 2008
Posts: 52
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.


SCJP 6, SCWCD 5
Success is how high you bounce when you hit bottom
Monica negi
Greenhorn

Joined: Sep 15, 2008
Posts: 6
Thanks Swathi..
I tried that, but is not working..
Giovanni De Stefano
Ranch Hand

Joined: Aug 17, 2004
Posts: 144
Hello Monica,

how are you setting the CLASSPATH in your system?

Are you using Windows or Linux?


SCJP 1.4
Monica negi
Greenhorn

Joined: Sep 15, 2008
Posts: 6
windows
Monica negi
Greenhorn

Joined: Sep 15, 2008
Posts: 6
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

Joined: Sep 05, 2008
Posts: 28
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

Joined: Aug 17, 2004
Posts: 144
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

Joined: Sep 15, 2008
Posts: 6
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.
 
GeeCON Prague 2014
 
subject: not able to set environment variables, HFSJ- beer example