求一个在Linux下运行GCC批量编译Java源文件的程序

来源:百度知道 编辑:UC知道 时间:2024/06/20 09:43:50
就是实现在一个目录下找到所有.java和.jar文件(包括子目录),将每一个找到的源文件用JDK命令行编译为相应的.class文件,放在源文件所在的目录下,同时用JDK命令行运行找到的.jar文件(这一条也可以不用做,做到更好,优先加分)。
最后,请在Linux下测试以后再贴出你的C代码。
我不知道我的问题是太难了,还是太简单了,让那么多Linux开发人员都无法正面回答。

要蹭分的话,我只会给我徒弟rise,其它人就别动这个脑筋了。

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <string.h>
void do_search_dir(char *path) {
DIR *dir;
char fullpath[1024],currfile[1024];
struct dirent *s_dir;
struct stat file_stat;
strcpy(fullpath,path);
dir=opendir(fullpath);
while ((s_dir=readdir(dir))!=NULL) {
if ((strcmp(s_dir->d_name,".")==0)||(strcmp(s_dir->d_name,"..")==0))
continue;
sprintf(currfile,"%s/%s",fullpath,s_dir->d_name);
stat(currfile,&file_stat);
if (S_ISDIR(file_stat.st_mode))
do_search_dir(currfile);
else
{
char *p;
p=currfile;
w