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?

Recommended Answers

All 6 Replies

Which OS are you in?

Windows, and i'm using JBuilder

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 myProgram

Try

java myProgram > output.txt

That will create a file, output.txt, that you can open and view the console output of your program.

Thanks, i'll try the .text u mentioned

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

use the following at the end of your code

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
in.readLine();

it will pause your command prompt and wait for an input.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.