aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes urgent help in running examples from hf jsp servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "urgent help in running examples from hf jsp servlets" Watch "urgent help in running examples from hf jsp servlets" New topic
Author

urgent help in running examples from hf jsp servlets

Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
I am not able to run the 1st example in hf jsp servlets...if u see that the command to run the example is:

javac -classpath /yourpath/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java.

One of the major problem is my pc is running in XP and in no way i can set my path...I have changed the environment variables but they dont work.
Like I have added a variable JAVA_HOME= c:\j2sdk1.4.2\bin; and later in system variable path i haveincluded ;JAVA_HOME;. ..but nothin works so i have to give the full path name each time I run javac.....could anybody help me on this who uses a XP machine???....also even when i try using set path or set class path from dos prompt they dont work ....path is not set and says javac not found and i have to use c:\j2sdk1.4.2\bin\javac. ned help in htis too???

So in the above case to run the hf example :

My tomcat cat path is:

C:\Program Files\Apache Tomcat 4.0\common\bin

so i used the command:

c:\j2sdk1.4.2\bin\javac -classpath /your path/tomcat/common/bin...

but im confused how do i write :

c:\j2sdk1.4.2\bin\javac -classpath C:/Program Files/Apache Tomcat 4.0/common/bin...

this doesnt work.....

also i tried to give the full path name in the code itself...

like import C:/Program Files/Apache Tomcat 4.0/common/bin/servlet.jar/javax.servelt.jar ..this gives errors...

could somebody kindly help me on this...urgent help is needed.

1> how to fix up the problem of set classpath and path in XP
2> How to run the first program from hf sevlets and jsp

Thanx
abhi


SCJP 1.4<br />Preparing for <br />SCJD and SCWCD
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
Originally posted by Abhi Chat:

My tomcat cat path is:

C:\Program Files\Apache Tomcat 4.0\common\bin

so i used the command:

c:\j2sdk1.4.2\bin\javac -classpath /your path/tomcat/common/bin...

but im confused how do i write :

c:\j2sdk1.4.2\bin\javac -classpath C:/Program Files/Apache Tomcat 4.0/common/bin...

this doesnt work.....



Thanx
abhi


Try this:

c:\j2sdk1.4.2\bin\javac -classpath "C:/Program Files/Apache Tomcat 4.0/common/lib/servlet-api.jar" -d classes src/Ch1Servlet.java

I've found it saves me headaches to install tomcat (and other java programs I have to call/reference via command line) in directories that do not contain spaces (specifically NOT "Program Files").

HTH

Todd Farmer
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
Also, if you add the following to your Path environment system variable (via Control Panel->System->Advanced->Environment Variables), you should be able to call javac directly without using the full path:

c:\j2sdk1.4.2\bin

This tells Windows where to find the javac.exe program.

Todd Farmer
Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
Abhi,

I'm running XP, and have set up my command line to run the following batch file (that I called jp.bat):


And I created myself a shortcut with the following "target", so this gets run when I click the shortcut:
C:\WINDOWS\system32\cmd.exe /kc:\bat\jp.bat
and had it "start in":
c:\projects

Adjust these paths depending on where you have installed things / save your batch file to.

A couple of other things I noticed in your post:
1. I see you are using servlet-api.jar in one sentence and servlet.jar later on. It ought to be the same. I'm using Tomcat 5.0.28 and need to use servlet-api.jar (hence it is in my classpath). If you are using Tomcat 4 (which I am not familiar with) you may need to user servlet.jar in both cases in which case, amend the classpath in the .bat file above above to reflect this.
2. You may find that if your path has a space in it (e.g. "Program Files"), that you need to put quotes round the path or at least that part that has a space. (But be wary of ending up with too many quotes - see next point).

To compile my code, I use the following:

where myfile.java is the file you want to compile. Note the quotes around CLASSPATH as I have spaces in the TOMCAT_HOME path which ends up in CLASSPATH.

Hope this helps.


Cheers,<br />Roger<br />SCJP 1.2, 1.4, SCBCD 1.3, SCWCD 1.4
Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
Thanx Guys..it worked....

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent help in running examples from hf jsp servlets