Hi Friends, I have wrriten a servlet. the basic purpose of this servlet is that, it will capture some info from HTML Page, then it will create one java class (physical file). then it will compile the file . and then it will call the method of that class. I am using JavaWebServer2.0 My servlet is Try.java . Interface CommonInterface.java the java class that i am generating runtime is implementing CommonInterface. All files are in package rulebasedvalidations. Now, all my class files(Try.class,CommonInterface.class )are in c:\JavaWebServer2.0\servlets\rulebasedvalidations my new source file(suppose named Rule5.java) is also in the same folder. In Try.java , i have written a code to compile a file Rule5.java Runtime rn = Runtime.getRuntime(); Process process = rn.exec("javac -classpath c:\\JavaWebServer2.0\\servlets\\ c:\\JavaWebServer2.0\\servlets\\rulebasedvalidations\\"+className); where className is Rule5.java but here i am getting an error like Superclass java.lang.Object of rulebasedvalidations.Rule5 not found. when i tried the same command from DOS prompt c:\> its working perfectly fine.
Could any one please help me to solve this problem? thanking in advance. -Pragati
I suspect what is happening is that when you do an exec from Java, the executed program does NOT get the normal set of Environment variables, but a reduced set. Therefore javac is NOT finding any of the standard libraries. You could use one of the exec variants in which you can set up environment variables and include CLASSPATH information, or you could add classpath for the standard library to the command line. I find it a lot easier to use the exec version which takes arrays of String rather than a single great long String that has to be parsed. Bill