• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

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 = "example.java" 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 ?
0
RdeLange
Asked:
RdeLange
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
CEHJCommented:
>>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 };

0
 
objectsCommented:
0
 
RdeLangeAuthor Commented:
no, i going directly from the java source using

int errors = com.sun.tools.javac.Main.compile(source);    

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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CEHJCommented:
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 };

            Execute.exec(command);
      }
//====================================================

and got the following output:

//====================================================

[parsing started bin\delme\A.java]
[parsing completed 100ms]
[parsing started bin\delme\B.java]
[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\commons-net-1.4.1.zip, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\dnsns.jar, C:\PROGRA~1\Java\JDK15~1.0_0\jre\lib\ext\jdom-1.0.zip, 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]
0
 
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
0
 
objectsCommented:
sourcepath won't find classes, only sources. So try adding the destination path to your classpath.
0
 
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?
0
 
objectsCommented:
what exactly is it you are trying to do?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now