943,895 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1918
  • Java RSS
Aug 20th, 2007
0

Window closes too quickly

Expand Post »
hi,
i just wrote my first java program, it compiles and runs and all, but the console window closes too quickly u can hardly see the output.
how can i rectify that?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
NewToJava is offline Offline
3 posts
since Aug 2007
Aug 20th, 2007
0

Re: Window closes too quickly

Which OS are you in?
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007
Aug 20th, 2007
0

Re: Window closes too quickly

Windows, and i'm using JBuilder
Reputation Points: 10
Solved Threads: 0
Newbie Poster
NewToJava is offline Offline
3 posts
since Aug 2007
Aug 20th, 2007
0

Re: Window closes too quickly

Not sure what the problem is, but you could try sending the output to a text file to view it in Notepad. Normally to run a java class file you would type something like
Java Syntax (Toggle Plain Text)
  1. java myProgram
Try
Java Syntax (Toggle Plain Text)
  1. java myProgram > output.txt
That will create a file, output.txt, that you can open and view the console output of your program.
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007
Aug 20th, 2007
0

Re: Window closes too quickly

Thanks, i'll try the .text u mentioned
Reputation Points: 10
Solved Threads: 0
Newbie Poster
NewToJava is offline Offline
3 posts
since Aug 2007
Aug 20th, 2007
0

Re: Window closes too quickly

first better way... is try to run programs in command prompt thats is the best way to start a learning step for java

install jdk 1.5 or latest 1.6

then set your class path

compile it

javac programname.java


and run

java programname

you will get the output in the command prompt console itself
Reputation Points: 119
Solved Threads: 7
Practically a Posting Shark
vinod_javas is offline Offline
871 posts
since Feb 2007
Aug 20th, 2007
0

Re: Window closes too quickly

use the following at the end of your code

Java Syntax (Toggle Plain Text)
  1. BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  2. in.readLine();
it will pause your command prompt and wait for an input.
Reputation Points: 66
Solved Threads: 56
Posting Pro in Training
Fungus1487 is offline Offline
459 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: HashTable Output
Next Thread in Java Forum Timeline: How do I deal with multiple button presses with KeyListener?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC