java


run java code with System.console class


How i will run this piece of java code????
import java.io.Console;
import java.util.Arrays;
/**
*
* #author User
*
*/
public class login{
boolean authenticate(String u,char[] c){
boolean x = false;
if(u=="soumitra"&&c.toString()=="paas")
{ x=true;}
return x;
}
public boolean login()
{int MAX_LOGINS=2;
Console con = System.console();
boolean auth = false;
if (con != null)
{
int count = 0;
do
{
String uname = con.readLine("Enter your username: ");
char[] pwd = con.readPassword("Enter %s's password: ", uname);
auth = authenticate(uname, pwd); // authenticate login info
Arrays.fill(pwd, ' '); // delete password from memory
con.writer().write("\n\n"); // output a couple of newlines
} while (!auth && ++count < MAX_LOGINS);
}
return auth;
}
public static void main(String args[]){
login obj=new login();
obj.login();
}
}
tried to run in Netbeansby rightclicking >>run....
got...
run:
BUILD SUCCESSFUL (total time: 0 seconds)
assuming the code is in a file named login.java...
compile with:
javac login.java
should produce login.class, run with:
java login
Oracle has a tutorial.
Try this in a terminal:
javac login.java
java login
The Output window is typically also your console window. Try making your Output window visible.
For C++, there is an option in Netbeans for where Console should read from.

Related Links

Reverse single linked list
Cache Control not Working in Firefox
Location Based Android Development
“Incoming Call” Activity may not be killed on Home Press
What is Android's SharedPreferences equivalent in Java?
how to mark avro field deprecated in JSON/avsc?
How do I keep my Android app running when it doesn't have focus?
Any easier way to construct dynamic deep nested json objects in Java
Change 6.51 to 6.50 in java BigDecimal
Auto delete database rows after an expiration date
I try to use the method repaint after paintComponent but its not work
Defining an equation outside of function
TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/JsonPrimitive.class
When given a pair of ints, I need my code to be able to return the int that is closest to 21 without going over [closed]
Spring Data MongoDB: Unit tests with Fongo
Tomcat and vagrant: how to get the same result as using war file

Categories

HOME
vim
wso2-am
homebrew
fme
icloud
azure-media-services
in-app-purchase
awesome-wm
maude-system
facebook-php-sdk
metatrader4
row
google-cloud-spanner
apache-cayenne
orchardcms
code-review
shared-hosting
predix
swiftlint
zapier
orleans
kudan
icloud-api
sqlcipher
numerical-methods
bootstrap-material-design
phpfox
entitlements
assistant
dbclient
file-rename
gsoap
sql-server-2012-express
catch-all
vsts-build-task
language-concepts
cloud-code
mmenu
picasso
retina-display
serverside-rendering
sqlite2
opshub
greenrobot-eventbus
pdf-reactor
core-plot
nand2tetris
turbogears
gpx
angular-resource
jsch
user-accounts
fault
jedis
python-c-api
dandelion
powercli
magma
sybase-asa
namecoin
pearson
arrow-keys
bind9
yt-project
parallel-data-warehouse
removechild
firebaseui
jwplayer7
react-native-listview
suffix-tree
oauth2client
uid
hsv
tcpserver
endeca-workbench
angular-local-storage
jsonpickle
qpainter
relocation
device-manager
bitcoinj
contenttype
wp-query
htmlcleaner
mysql-error-1062
poller
rtmfp
datagridviewcolumn
cloud-connect
imdbpy
sitemesh
tws
django-nonrel
lcs
typoscript2
jquery-knob
rdoc
broken-links
propertyeditor
jspinclude
netbeans-6.9
cufon
netdna-api
mongomapper
firefox-5
sef
photoshop-cs4
aquaticprime
procedural-music

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App