Home arrow static arrow Java Programming [Archive] - compiling java program thru code
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - compiling java program thru code
This topic has 2 replies on 1 page.

Posts:35
Registered: 1/31/02
compiling java program thru code  
Jun 16, 2004 5:14 PM



 
Hi,

I am trying to compile the java code thru a program itself. Below is the code snippet.

String directory = "c:\javacodes\*.java";

String[] args = new String[]{"-classpath","c:/lib/xyz.jar", "-sourcepath", directory};

int status = com.sun.tools.javac.Main.compile(args);

This however results in a compilation error saying : javac: no source files

If i specify a individual filename it compiles fine, but i am not able to compile using the wildcard character.

Any help is appreciated.
 

Posts:2,206
Registered: 8/15/02
Re: compiling java program thru code  
Jun 16, 2004 5:22 PM (reply 1 of 2)



 
Thats because wildcard character are interpreted by the shell before being passed off to the command. Since you are not going throough the shell, there is nothing to interpret the wildcard and your code will be looking for a file called *.java.
 

Posts:35
Registered: 1/31/02
Re: compiling java program thru code  
Jun 16, 2004 5:25 PM (reply 2 of 2)



 
Thanx for the input .. i do understand now.

sharad
 
This topic has 2 replies on 1 page.