wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Program for Console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Program for Console" Watch "Program for Console" New topic
Author

Program for Console

Sonali Sehgal
Ranch Hand

Joined: Jul 09, 2009
Posts: 75
I am preparing for SCJP 6.
Can you please explain java.io.Console class with the help of small program?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3102
    
  40

There are only few methods in java.io.Console class
I would recommend you to read the javadoc (please have a look at the above link). And then you should solve some mock exam questions too.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Sonali Sehgal
Ranch Hand

Joined: Jul 09, 2009
Posts: 75
I tried doing a program and there is a error coming in can you please help??

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3102
    
  40

Sonali Sehgal wrote:I tried doing a program and there is a error coming


What is the error you are getting there?
I can see a little error that the "name" variable is not defined.
Sonali Sehgal
Ranch Hand

Joined: Jul 09, 2009
Posts: 75
Thanks a lot Devaka I got the solution and another thing I was using the version of Java that is 1.5 to fix the problem it should be of version1.6
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Note that netbeans does not support the console class internally.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

When you call System.console(), it will only return an instance of Console class if one is available. If the program is running in an environment which doesn't have a console, then null is returned...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Sonali Sehgal
Ranch Hand

Joined: Jul 09, 2009
Posts: 75
Hi Wouter and Ankit,


So in order to execute the program will the upgrading the version of java from 1.5 to 1.6 will help or only console needs to be added to netbeans ....As Kathy says java.io.Console is the latest in version 1.6....I also tried this program on another computer with version 1.6 java it was successfully executing........
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

If you want to use java.io.Console you need to hava java 1.6. The problem is that if you develop in netbeans, the console class will not be available because netbeans does (not yet) support it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program for Console