My program uses JDK source as test suite, does some modification on those Java source codes and generates very similar source files with same file names and hierarchy, let's call them NEW source. Now my target is to make sure these NEW source are compilable.
You can compile the source just like you compile your own program "javac *.java". Or do you mean that you want to compile them programmatically in your test suite? If that's the case, the easiest, but probably least flexible, solution is to use Runtime.exec(). See the Java API documentation for the version of Java you are using for details.
Alternatively, you may want to look at the the classes available in tools.jar. I'm not sure how much documentation is publicly available, but it contains supporting classes for many of the tools you use in Java development, such as javac, java, and javadoc. I really don't know enough about what is available to provide much help, so I hope someone else can.
I hope I've helped point you in the right direction here. If not, please let us know where you can help. Try giving us some more specific information about the problems you are encountering.
Note that she's not talking about src.zip; she's talking about the source for the JDK, which includes some funky stuff. In particular, there are files named *.java which nevertheless don't contain valid Java source; rhere are preprocessing instructions in them. To build the JDK from source, you pretty much have to use their makefile system, which runs the various tools that do that preprocessing and all sorts of other funky stuff.
Nancy, could you possibly use the contents of the src.zip that comes with the J2SDK download instead of using the raw JDK source? This file contains only valid Java source; instead of those funky files in java/nio, it contains the results of running the preprocessor, all perfectly valid Java source.
I noticed that there's a "windows build instructions" file under root dir of JDK source, it seems tons of work and tools needed. So I decided to use pure source code from src.zip instead. Thanks for you all.
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, the permaculture playing cards