aboutsummaryrefslogtreecommitdiffstats
path: root/mypath/runjv.c
blob: 74efb72d1c30448df399643c754636e66866e4e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
已复制!
#include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _WIN32 #define DELETE_COMMAND "del" #else #define DELETE_COMMAND "rm -rf" #endif int main(int argc, char* argv[]) { char* command; if(argc!=2) { printf("Number of parameters Wrong!\n"); printf("Usage: runjv <filename>\n"); return 1; } command=(char*)malloc(sizeof(char)*(strlen(argv[1])+10)); char* classname=strtok(argv[1],"."); sprintf(command,"javac %s.java",classname); int command_status=system(command); if(command_status!=0) { printf("Compile Failed!\n"); return -1; } sprintf(command,"java %s",classname); system(command); sprintf(command,"%s %s.class",DELETE_COMMAND,classname); system(command); return 0; }