Run Java Application works but not Run
Posted: Fri Jun 27, 2003 12:56 am
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 ?
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 ?