This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Java Command problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Java Command problem" Watch "Java Command problem" New topic
Author

Java Command problem

Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
hi everyone .

i am facing a strange problem basically i want to redirect output "JAVA MYCLASS"
command to my specific file.

Description :

Actually i want to redirect the output of "JAVA MYCLASS" command.
where the MYCLASS would be the name of the compiled class at specific
location.
i tried following but got no output


but at the end the output.txt is empty

please help me

waiting for your suggestion

regards
Amir Iqbal

JCE: Please use Code Tags - they preserve your code format and make reading easier.
[ August 14, 2008: Message edited by: Joe Ess ]

i am Java +ve Now !
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

Your code does not compile:


Please Post Real Code.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
ok so please omitt that line with

System.out.println("..............");
or
basically it is a static method in ExecuterClass
********************************
ExecuterClass.show(String str,boolean b){

if (b == true)
System.out.println(str);
}
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

That fixes one of the two compile errors.
Abhijeet Nalawade
Greenhorn

Joined: Apr 01, 2007
Posts: 20
Fail to understand what is to be achieved. Explain it bit more clearly.
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
just comment that line..... yar it will fix all the errors... coz it is just a debugging statment....
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

Are you going to fix the error on line 76?
Please Show Some Effort. I'm getting the impression that you just want us to do your work for you.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Originally posted by Amir Iqbal:
just comment that line..... yar it will fix all the errors... coz it is just a debugging statment....


Joe's intention was not for him to fix your code but to make you realise the importance of Posting real code.
Anyone over here can fix your code of compilation error but the point is that you must post your question clearly.
It wastes the time of the people trying to help you if your code has compilation errors.

The other compilation error Joe is talking about isnt a debug statement, but it is the core of your program execution, you are calling when is not defined.

ExecuterClass2.java:76: cannot find symbol
symbol : variable cmd
location: class ExecuterClass2
Process proc = rt.exec(cmd);
^


BTW, this code is directly out of this article
If you are having problems understanding some article or sample code, then please QuoteYourSources
[ August 18, 2008: Message edited by: Nitesh Kant ]

apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Command problem
 
Similar Threads
Runtime.exec to wait for external application
Implementing runAs in Java
Capturing javac outputstream
What is wrong with my Eclipse3.3.1 Setting??
who can my question about this code