-
stdout with JNI
Hi, i am trying to redirect the stdout to a file, i used JNI to run JBoss from jar file but i canīt redirect the output can some one help me here its the code i am trying to do:
Code:
int main(int argc, char **argv) {
FILE *stream;
char linea[1024];
JNIEnv* env = create_vm();
stream = freopen("file.txt", "w", stdout);
invoke_class( env );
fprintf(stream,stdout);
//stream = freopen("CON", "w", stdout);
/*stream = fopen("file3.txt","w");
stdout>stream;*/
/*while(stdout!=NULL)
fprintf(stream,stdout);*/
getchar();
}
i have alredy play with stdout but i canīt manipulate it
Thanks in advance
-
Maybe perform the redirect before you create the VM ?
-
I have already done it but it throws me the ERROR compiling:
Error 3 error C2275: 'JNIEnv' : illegal use of this type as an expression c:\documents and settings\penuelas\my documents\visual studio 2005\projects\saulvm\saulvm\saul.c 66
Error 4 error C2065: 'env' : undeclared identifier c:\documents and settings\penuelas\my documents\visual studio 2005\projects\saulvm\saulvm\saul.c 66
any idea?
-
Maybe write it in C then?
Code:
JNIEnv* env;
stream = freopen("file.txt", "w", stdout);
env = create_vm();
-
It works thanks. I have not programed in C since first semesters of carrer thanks