I have the following in the CLASSPATH = .;
I am using Windows 2000
I have the directory structure as C:\Java\sample
All my programs are written under the directory sample.
This is the piece of code I am trying to RUN...
---------------------------
import java.io.*;
class HelloYou {
public static void main (String args[]) {
byte name[] = new byte[100];
int nr_read = 0;
System.out.println("What is your name?");
try {
nr_read = System.in.read(name);
if (nr_read!=0)
System.out.println("Value of nr_read - >"+nr_read);
System.out.print("Hello ");
System.out.write(name,0,nr_read);
}
catch (IOException e) {
System.err.println ("Error.");
}
}
}
--------------------------
This code compiles successfully. Now when I am trying to execute the command "Run Java Application", the DOS prompt opens up and after printing the intial stuff, waits for user prompt. And then program keeps flowing correctly.
However, if I execute the command "Run" a dialog box opens up having 3 fields.
1. Command -> C:\j2sdk1.4.1_03\bin\java.exe
2. Parameter -> HelloYou ABC
3. Initial Folder -> c:\Java\sample
This when executed, and output selected as Textpad, then control shifts to catch block and "Error" is printed out.
Can anyone explain why ?
Run Java Application works but not Run
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Change your catch block to
Then you will see which Exception is thrown.
If that does not help you in finding the error, come back here.
And tell us
- what you enter
- what exactly is output[/code]
Code: Select all
catch (IOException e)
{
System.err.println ("Error. " + e);
}
If that does not help you in finding the error, come back here.
And tell us
- what you enter
- what exactly is output[/code]
Re : Run Java Application works but not Run
This is the output ---
What is your name?
Error.java.io.IOException: The handle is invalid
Any suggestion ?
What is your name?
Error.java.io.IOException: The handle is invalid
Any suggestion ?
Are you running the Java program from Textpad?
Then look at http://www.textpad.com/forum/viewtopic. ... t=redirect
Then look at http://www.textpad.com/forum/viewtopic. ... t=redirect
Capture Output unchecked
Thanks for the reply. As was mentioned, I unchecked the "Capture output" option.
This resulted in opeing up the DOS window and all the results being displayed properly.
This is the same as executing the option "Run Java Application".
I was hoping to capture the output in Textpad window. That is why I was executing the command "RUN" and checking the option "Capture Output". But that does not seem to work.
Regards,
Arijit
This resulted in opeing up the DOS window and all the results being displayed properly.
This is the same as executing the option "Run Java Application".
I was hoping to capture the output in Textpad window. That is why I was executing the command "RUN" and checking the option "Capture Output". But that does not seem to work.
Regards,
Arijit