When you run the command from your unix shell javac will pick up the class path from an environment variable set for that shell.
I suspect that you need to explicitly set the classpath either as part of the command with a "-cp <classpath here>" or use the form of Runtime.exec(String[],String[]) that lets you set environment variables and specify the classpath as it is done in your shell. cheers > -----Original Message----- > From: Dinesh Abichandani [SMTP:[EMAIL PROTECTED] > Sent: 25 March 2003 05:57 > To: [EMAIL PROTECTED] > Subject: problem exec javac from servlet > > hi there > I am trying to execute javac command from my servlet but it not letting me > do it . i am using tomcat server. here is the code wht i am trying to > run: > > Process proc1=null; > Runtime rt1 = Runtime.getRuntime(); > proc1 = rt1.exec(new > String[]{"javac","/vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/example > s/WEB-INF/classes/HelloWorldExample.java"}); > BufferedReader err1 = new BufferedReader(new > InputStreamReader(proc1.getErrorStream())); > String line1 = null; > while ( ( line1 = err1.readLine()) != null) > out.println( line1); > and the error i get is: > > /vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/examples/WEB-INF/classes/ > HelloWorldExample.java:8: package javax.servlet does not exist import > javax.servlet.*; ^ > /vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/examples/WEB-INF/classes/ > HelloWorldExample.java:9: package javax.servlet.http does not exist import > javax.servlet.http.*; ^ > /vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/examples/WEB-INF/classes/ > HelloWorldExample.java:17: cannot resolve symbol symbol : class > HttpServlet location: class > HelloWorldExample public class HelloWorldExample extends HttpServlet { ^ > /vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/examples/WEB-INF/classes/ > HelloWorldExample.java:20: cannot resolve symbol symbol : class > HttpServletRequest location: class > HelloWorldExample public void doGet(HttpServletRequest request, ^ > /vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/examples/WEB-INF/classes/ > HelloWorldExample.java:21: > cannot resolve symbol symbol : class HttpServletResponse location: class > HelloWorldExample HttpServletResponse response) ^ > /vol1/people/dinesh/jakarta-tomcat-4.0.6/webapps/examples/WEB-INF/classes/ > HelloWorldExample.java:22: cannot resolve symbol symbol : class > ServletException location: class > HelloWorldExample throws IOException, ServletException ^ 6 errors > > if i run this command in my unix shell it works fine but not when i try to > run this command from servlet. i have a copy of servlet.jar file in lib > directory of tomcat and a classpath to it is also set in my .login file. > > please advice wht need to be done? > > thanks > dinesh > > __________________________________________________________________________ > _ > To unsubscribe, send email to [EMAIL PROTECTED] and include in the > body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html -- It is the strict policy of Truworths that its e-mail facility and all e-mail communications emanating therefrom, should be utilised for business purposes only and should conform to high professional and business standards. Truworths has stipulated certain regulations in terms whereof strict guidelines relating to the use and content of e-mail communications are laid down. The use of the Truworths e-mail facility is not permitted for the distribution of chain letters or offensive mail of any nature whatsoever. Truworths hereby distances itself from and accepts no liability in respect of the unauthorised use of its e-mail facility or the sending of e-mail communications for other than strictly business purposes. Truworths furthermore disclaims liability for any unauthorised instruction for which permission was not granted. Truworths Limited accepts no liability for any consequences arising from or as a result of reliance on this message unless it is in respect of bona fide Truworths business for which proper authorisation has been granted. Any recipient of an unacceptable communication, a chain letter or offensive material of any nature is requested to notify the Truworths e-mail administrator ([EMAIL PROTECTED]) immediately in order that appropriate action can be taken against the individual concerned. ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html