How to compile from a java program a lot of java programs that I have genereated

I tried to compile a bunch of programs that my program has generated
But it fails.
I can compile one file
But if I give a source path it fails. It seems that the sourcefile option does not work since the -cp option works
my string is

String sourcePath = "c:\\project\\src";
Stroug outPath     = "c:\\project\\classes";
String sourcefile            = "*.java";

tring [] source = {"-verbose","-sourcepath",sourcePath,"-d",outputPath, sourcefile};

if sourcefile = "" and is in the current directory it works.
Wildcard seem not to work
How to solve or is it just a bug in 1.5 ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>Wildcard seem not to work

How are you using that array? The shell needs to interpret the glob

A command array should be something like

String[] command = {"cmd.exe", "/c",  "javac", "-verbose", "-sourcepath", sourcePath, "-d", outputPath, sourcefile };


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RdeLangeAuthor Commented:
no, i going directly from the java source using

int errors =;    

But never the matter, it doesn't work different from starting from dos.
I have there the same problem that javac doesn't look to the sourepath
But be aware, I want a bunch of source compiled, just like ANT does.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Just done the following:

      public static void main(String[] args) {
            String sourcePath = "bin\\delme";
            String outputPath = "bin\\classes";
            String sourcefile = "bin\\delme\\*.java";
            String[] command = {"cmd.exe", "/c",  "javac", "-verbose", "-sourcepath", sourcePath, "-d", outputPath, sourcefile };


and got the following output:


[parsing started bin\delme\]
[parsing completed 100ms]
[parsing started bin\delme\]
[parsing completed 0ms]
[search path for source files: [bin\delme]]
[search path for class files: [C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\rt.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\jsse.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\jce.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\charsets.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\commons-codec.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\commons-httpclient.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\commons-logging.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\commons-net-1.4.1.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\dnsns.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\jdom.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\localedata.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\log4j.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\sunjce_provider.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\sunpkcs11.jar, .]]
[loading C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\rt.jar(java/lang/Object.class)]
[checking A]
[wrote bin\classes\A.class]
[checking B]
[wrote bin\classes\B.class]
[total 761ms]
Mayank SAssociate Director - Product EngineeringCommented:
>>  I want a bunch of source compiled, just like ANT does.

If you have Ant, maybe an idea would be to create the build-file instead and invoke Ant
sourcepath won't find classes, only sources. So try adding the destination path to your classpath.
RdeLangeAuthor Commented:
Sorry to say but sourcepath DOES NOT find sources, thats the main problem.
It look likes it is not working. Could this be a java version problem?
what exactly is it you are trying to do?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.