Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Compile a java class from within another java program using tool.jar (http://www.velocityreviews.com/forums/t136659-compile-a-java-class-from-within-another-java-program-using-tool-jar.html)

Mathias Conradt 09-07-2004 12:28 AM

Compile a java class from within another java program using tool.jar
 
I need to compile a java class from within another java program.

Using
Runtime.getRuntime().exec("javac ...
works fine. But I would like to user the javac class from Sun's
tool.jar directly.

When I try to compile just the same file using the Sun tool.jar:

String arg[] = {"-sourcepath","c:/projects/pm/WEB-INF/src","-d","c:/tmp/pm","c:/path/to/class.java"};
com.sun.tools.javac.Main.main(arg);

it gives me the following short stack trace:
"Error: Can't read <path_to_class.java>"

Any idea what the problem might be? The java class to be compiled is
given as absolute path and exists. I don't think that I have any other
application using the file at the same time. And the path is also
correct.

Mathias

Andrew Thompson 09-07-2004 07:28 AM

Re: Compile a java class from within another java program using tool.jar
 
On 6 Sep 2004 17:28:34 -0700, Mathias Conradt wrote:

> "c:/path/to/class.java"


Try..
"C:/path/to/class.java"

If that fails, try Linux. ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Mathias Conradt 09-08-2004 09:44 PM

Re: Compile a java class from within another java program using tool.jar
 
Andrew Thompson wrote:
> Try..
> "C:/path/to/class.java"
>
> If that fails, try Linux. ;-)


This didn't make any difference, but meanwhile I found the problem.

Runtime.exec accepts a term including a wild card for the java files to
be compiled: /path/to/Some*.java

The compile-Method in tool.jar does not accept a wild card, therefore I
had to list all one by one. But it's working. Fortunately it's just
three files.

Mathias

Andrew Thompson 09-08-2004 09:55 PM

Re: Compile a java class from within another java program using tool.jar
 
On Wed, 08 Sep 2004 23:44:37 +0200, Mathias Conradt wrote:

> The compile-Method in tool.jar does not accept a wild card, therefore I
> had to list all one by one.


Try giving it the name of a file containing
the entire list of Java files to be compiled,
one on each line. From memory, that works..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology


All times are GMT. The time now is 09:49 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.