stdout with JNI

This is a discussion on stdout with JNI within the C Programming forums, part of the General Programming Boards category; Hi, i am trying to redirect the stdout to a file, i used JNI to run JBoss from jar file ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    14

    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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Maybe perform the redirect before you create the VM ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    14
    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?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Maybe write it in C then?
    Code:
    	JNIEnv* env;
    	stream = freopen("file.txt", "w", stdout);
    	env = create_vm();
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    14
    It works thanks. I have not programed in C since first semesters of carrer thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Case Statement
    By danlee58 in forum C Programming
    Replies: 16
    Last Post: 11-23-2008, 08:46 PM
  2. Replies: 2
    Last Post: 07-12-2008, 01:00 PM
  3. Redirect stdout
    By GoLuM83 in forum C Programming
    Replies: 6
    Last Post: 12-15-2006, 04:17 PM
  4. forcing stdout of external program to be line-buffered
    By FreakCERS in forum C Programming
    Replies: 4
    Last Post: 09-17-2006, 01:46 PM
  5. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21