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???
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").
Joined: May 28, 2004
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:
This tells Windows where to find the javac.exe program.
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.