Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

program execution

Status
Not open for further replies.

poland

Technical User
Feb 11, 2002
3
JP
I have two programs and both program execute but i can't see results(it flashs and disapears )
Am i missing something?Is my JBuiler working correctly?
Here is code both programs
Please help me


Program 1
class Foo
{
public int x = 10;
public static int y = 10;
};

public class Q5
{
public static void main (String [] args)
{
Foo a = new Foo ();
Foo b = new Foo ();
Foo c = new Foo ();

a.x = 5;
b.x = a.x * 20;
c.y = 75;
a.y = c.y / 3;
c.x = 30;

System.out.println ("a.x = " + a.x);
System.out.println ("a.y = " + a.y);
System.out.println ("b.x = " + b.x);
System.out.println ("b.y = " + b.y);
System.out.println ("c.x = " + c.x);
System.out.println ("c.y = " + c.y);
}
}


Program 2

public class Edu1 {
public static void main(String[] args) {
String line = null;

System.out.print("Please enter your name: ");
try {
// get user input from console
BufferedReader reader = new BufferedReader
(new InputStreamReader(System.in));

line = reader.readLine ();
}
catch (Exception e) {
e.printStackTrace ();
System.exit(1);
}

System.out.println("\nHello " + line);
}
}
 
Apart from not including 'import java.io.*;' in the first line of the Edu1 they look fine.

I can see how JBuilder might have troubles with the second one is it is awaiting input from STDIN. Have you tried excuting the classes from a command prompt instead of thru your IDE ?
RjB.
 
It seems to me that you have a property somewhere that tells the Window or Frame to disappear or clear. Toggling that should leave the code visible as you do not have any code to flush the screen, in other words, you would see all the output in the command line prompt using a standard Sun Java Virtual Machine.
 
Hi poland,
I tried executing the programs, and they worked fine. First I packaged them into a single package, using the package statement. Then, in the project properties, I chose the class to be run as Edu1. When I run the program, it asked for name in the message area. When I typed in my name and pressed the Enter, my name was printed.

I hope it helps.

Regards,
Rajarajan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top