Make System.in read input from a command prompt

How can i make System.in read input from a command prompt which is opened after program
is started. Please note that program starts without commad promt. Can u plz help?
sharmila

System.in DOES read from the command shell that you start the app in.
What you don't have is a prompt.
You should know about Java Almanac. There are code samples for simple things like I/O that everyone should know about. There's an example there to help you.
MOD

Similar Messages

  • Read Input from console !!!

    Im am very new to java and trying to learn java ..
    Now the problem i have is, I have to read input from console without using the BufferReader method..
    Please tell me how to go about it..
    I have a assignment to complete and im not able to figure out the way out.
    Help ..

    http://java.sun.com/j2se/1.4.1/docs/api/java/lang/System.html
    Read first about the System class provided by Java.
    Select the 'in' method of System class and it will take
    you to the InputStream.
    http://java.sun.com/j2se/1.4.1/docs/api/java/io/InputStream.html
    An essay way of reading input is:
    "value?"=System.in.read();
    Try and see if this works. It will not use the
    BufferReader portion, but it gives you another way
    of reading from the console.

  • How to read input from handheld scanner on a keyboard port

    Hi everybody,
    i have an application that should read input from a scanner.
    If i use a jTextField to input scanned data it works fine.
    the problem is that i don't want to use any text component to input data into it.
    And if i set the jtextField not visible then the focus sustem doesnt work.
    I tried to read a buffered input stream from System.in but it doesnt work.
    If the scanner was installed on a serial port i could use javax.comm to monitor it.
    But unfortunately i must use the keyboard wedge thing...
    Do you have any ideas?
    Thank you in advance

    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))
    null

  • How to read multiple lines from a command prompt?

    I usually read from a command prompt like this:
    String answer;
    System.out.println("Please enter the required data");
    try {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    answer = reader.readLine();
    reader = null;
    } catch (Exception e) {
    System.out.println("There was an exception trying to read " + e);
    answer = "";
    This has worked fine for years when all I wanted was one line answers.
    Now I am trying to prompt for multiple line answers. Is there a way to read into a string array rather than just a string? What class would I use for that?
    Thanks a lot!

    The easiest approaches would be to read a line at a time until you've read enough lines, whether by a known fixed line count, or a token count, or by reading some sentinel toek, OR read a token at a time using Scanner.next() until you've determined you're done. Which one is more appropriate depends on your situation.

  • Code for how to read an integer array from the command prompt...

    hello,
    Could anyone give me the code for how to read an integer array from the command prompt...its very urgent!..

    If you are using a recent version of Java (5 or later) you can use Scanner:
    http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
    That page has some example code on it, too.

  • How to execute a scenario from Windows command prompt

    Hi,
    I have a package which is executing fine from Designer. But the same scenario if I am trying to execute from windows command prompt, then it is giving error.
    The package is getting a refresh variable, passing to interface which is creating a file from table, this file is then getting FTP'ed to another server.
    I am executing following command -
    startscen OB_TAB_TO_FILE_PKG 001 ODICTX "-v=2"
    The error is -
    A JDK is required to execute Web Services with OracleDI. You are currently using
    a JRE.
    OracleDI: Starting scenario OB_TAB_TO_FILE_PKG 001 in context ODICTX ...
    java.sql.SQLException: socket creation error
    at org.hsqldb.jdbc.jdbcUtil.sqlException(jdbcUtil.java:67)
    at org.hsqldb.jdbc.jdbcConnection.<init>(jdbcConnection.java:2451)
    at org.hsqldb.jdbcDriver.getConnection(jdbcDriver.java:188)
    at org.hsqldb.jdbcDriver.connect(jdbcDriver.java:166)
    at com.sunopsis.sql.SnpsConnection.u(SnpsConnection.java)
    at com.sunopsis.sql.SnpsConnection.c(SnpsConnection.java)
    at com.sunopsis.sql.i.run(i.java)
    DwgJv.main: Exit. Return code:-1
    Please let me know where I am going anything wrong.
    Thanks,
    Himanshu

    Hi,
    you need to make the necessary changes to the %odi%\bin\odiparams.bat config file, under the "Repository Connection Information" section so that startscen knows how to extract metadata from your repository.
    You apparently have left the default settings to the Hypersonic demo repository. Is that the technology your repository is hosted on?

  • How to read files from the menu prompt

    Hi all the experts here, help me plz
    this is the menu
    R - Read a batch of student marks from a file
    D - Display a table of student results
    Q - Quit from the program
    when user press R the program has to read a file. The default file name is results1.txt
    but my teacher is gonna change the file name when she tests it.
    so i can't put the fixed file name. i have to read the file name from the command
    prompt
    The user will type the file name and i just have to read that file..but..its hard for the
    biginner...THX guys

    help me guys plz im really stuck man
         public char promptMenu()
              System.out.println ("R - Read a batch of student marks from a file");
              System.out.println ("D - Display a table of student results");
              System.out.println ("Q - Quit from the program");
              char answer = Keyboard.readChar();
              return answer;
    after user press 'R'
    then i have to read a file whatever the user enters..

  • Starting a WSAD server from the command prompt and not from the IDE UI

    Hi,
    is there a way to run the WSAD server from the command prompt instead of using the IDE UI . i have tried starting the server from the Directory i have installed WSAD " D:\Program Files\IBM\WebsphereStudio\runtimes\base_v5\bin>startServer.bat" but it gives the Following error " The system cannot find the path specified." i am working . do i have to specify the workspace that i am currently working on

    to see if the network adapter has registered with OPMN run: opmnctl status
    the 6200 message is a timeout which can be set in opmn.xml, the reports server(s) and other processes managed by OPMN should still stop.
    Try opmnctl stopall or opmnctl shutdown
    Does the timeout shows up regularly ie can you repeat it?
    After the stopall or shutdown try to start everything up again and try to stop the single reports server process again.

  • Error 57 in invoking sqlplus command from DOS command prompt in Oracle Serv

    I have a Oracle 11G server which has suddenly shutdown due to power cut-off. Now when I restart the system and trying to connect to database invoking the sqlplus as sysdba from DOS command prompt - I am getting following errors
    C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
    Error 57 initializing SQL*Plus
    Error loading message shared library
    Can anyone help me please ?

    Yes sure!! .. The details of alert logs for today is herewith -
    Thu Feb 28 12:30:02 2013
    kewastUnPackStats(): bad magic 1 (0x0DFE82DA, 0)
    kewastUnPackStats(): bad magic 1 (0x0DFE82DA, 0)
    Thu Feb 28 12:36:02 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:36:19 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m000_5180.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m000_5180.trc:
    ORA-00204: error in reading (block 1, # blocks 1) of control file
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:36:40 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:37:08 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:37:28 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:37:50 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:38:07 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m000_6256.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m000_6256.trc:
    ORA-00204: error in reading (block 1, # blocks 1) of control file
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:38:12 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:38:34 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:38:56 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:39:31 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:39:47 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m001_7628.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:39:49 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m001_7628.trc:
    ORA-00204: error in reading (block 1, # blocks 1) of control file
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:40:10 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:40:31 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_ckpt_3160.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Thu Feb 28 12:40:48 2013
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m002_2748.trc:
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.
    Errors in file d:\app\collbrs\diag\rdbms\collbrs\collbrs\trace\collbrs_m002_2748.trc:
    ORA-00204: error in reading (block 1, # blocks 1) of control file
    ORA-00202: control file: 'D:\APP\COLLBRS\ORADATA\COLLBRS\CONTROL01.CTL'
    ORA-27070: async read/write failed
    OSD-04006: ReadFile() failure, unable to read from file
    O/S-Error: (OS 1117) The request could not be performed because of an I/O device error.

  • Not running from the Command Prompt.

    I have developed a SMTP based mail dispatch software using netbeans and Javamail. It is working fine while running within netbeans. But while runing it from the command prompt after making a build of it from netbeans, it gives error File not found exception for javamail as below.
    =================================================
    DEBUG: not loading resource: /META-INF/javamail.address.map
    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre1.5.0_07\lib\java
    mail.address.map (The system cannot find the file specified)
    exception thrown:

    JavaMail attempts to load resources from many places. The fact that some
    are not found is not necessarily a problem. JavaMail will fall back to
    resources included in the mail.jar file.
    You need to look further in the debug output for the source of your problem.
    (I assume you've included mail.jar in your CLASSPATH when running
    your program from the command prompt. See README.txt included
    with JavaMail.)

  • Setting classpath from the command prompt

    each time i try to set the classpath from the command prompt it is not always well done . can someone give a good format
    i.e set classpath = ;c:\document and settings\ luke

    each time i try to set the classpath from the command
    prompt it is not always well done . can someone give
    a good format
    i.e set classpath = ;c:\document and settings\ lukeThe best way is not doing it at all.
    Anyway, try:
    set classpath = ".;c:\document and settings\luke"

  • How can i run application client from the command prompt ?

    Hi,
    I'm new to java & EJB. so can any body tell me the command to run the application client from the command prompt. Here is the code to print hello world:
    /* Remote interface */
    public interface Hello extends javax.ejb.EJBObject
         public String hello() throws      java.rmi.RemoteException;
    /* Home interface */
    public interface HelloHome extends javax.ejb.EJBHome
         Hello create() throws java.rmi.RemoteException, javax.ejb.CreateException;
    /* Stateless session bean class */
    public class HelloBean implements javax.ejb.SessionBean
         private javax.ejb.SessionContext ctx;
         public void ejbCreate(){
              System.out.println("ejbcreate()");
         public void ejbRemove(){
              System.out.println("ejbRemove()");
         public void ejbActivate(){
              System.out.println("ejbActivate()");
         public void ejbPassivate(){
              System.out.println("ejbejbPassivate()");
         public void setSessionContext(javax.ejb.SessionContext ctx){
              this.ctx=ctx;
         public String hello(){
              System.out.println("hello()");
              return "Hello, world!";
    /*Client class */
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import java.util.Properties;
    public class HelloClient
         public static void main(String[] args) throws Exception{
              Properties props=System.getProperties();
              Context ctx=new InitialContext(props);
              Object obj=ctx.lookup("HelloHome");
              HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
              Hello hello=home.create();
              System.out.println(hello.hello());
              hello.remove();
    I have stored .java files in c:\ejb
    I have successfully created the .class files using javac command in the following directory :
    c:\ejb
    I have also created Helloworld.ear file in c:\ejb using sun application server which contains the following files:
    ejb-jar-ic.jar
    app-client-ic.jar
    sun-j2ee-ri.project
    application.xml
    sun-application.xml
    Manifest.mf
    But the problem is that i'm not able to run the HelloWorld.class file successfully from the command prompt. So please suggest me the comand.
    Thanx in advance.
    Best regards,
    Pankaj

    Hi
    You can run this code from the command prompt in the same way as you run any other simple java program. The only thing is you need to set the Home and Local interfaces in the classpath.And obviously if u had deployed the bean in ur app server container, then its all over.
    And one more thing is that u need to set the provider URL in the InitialContext created in the client program.
    Thanks
    Arun B

  • Calling  r25con32.exe  from the command prompt

    how to call r25con32.exe from the run prompt.

    Duplicate:
    Calling  r25con32.exe  from the command prompt
    :)

  • "Reader Extensions ES" in Command Prompt.

    Is it possible to use the "Reader Extensions ES" through command prompt. Kindly advice me.
    Thanks,
    Prabudass

    Ah, this is the first mention you have made of an Adobe product. Now,
    LiveCycle Designer does not open in a browser, so I assume you are
    doing one of these
    * Opening Acrobat in a browser
    * Opening Adobe Reader in a browser
    * Opening a preview in Designer
    * Something else?
    If you can describe in detail what you are doing with Adobe products
    it may help to focus. HOWEVER, you have added to message topics which
    seem to have NOTHING to do with your question. Does your question
    connect to "Reader Extensions ES in Command Prompt" in some way that
    isn't clear? If not, please post ONE new message with a suitable title
    in the specific forum for the Adobe product involved. Thanks and good
    luck,
    Aandi Inston

  • Requesting user input from UNIX command window

    New to this forum, and relatively new to Java......question for you......
    Currently, I am able to request a .txt file from a user in my unix command window by having them type in the following command:
    java Game (nameOfTextFile).txt
    with the following code:
    public class Game {
    public static void main(String[ ] args) {
    try{
    reader = args[0];
    catch(Exception g){
    System.out.println(g);
    where 'reader' holds the .txt file.
    What I would like to do is as soon as the user types in the command:
    java Game
    it gives them the line:
    "Please type the file to be input"
    and at this point they type in:
    (nameOfTextFile).txt
    and then I can start working with the text file.
    Any ideas?
    Thanks

    public class Game {
    public static void main(String[ ] args) {
    try{
    reader = args[0];
    catch(Exception g){
    System.out.println(g);
    }This class will not compile. The variable 'reader' is not declared anywhere.
    You could create a shell program. When the user enters the name of the shell program at the command prompt, it gives them the prompt to enter the file to be input. And then from within the shell program you call the java program with the name of the file.

Maybe you are looking for

  • Kernel Panic when launching safari OS X mavericks

    Hello, i would really appreciate your input guys. Sometimes I am getting kernel panics when i launch safari, this occurs mostly when i turn mac on and then launch the safari, when i launch something else it wont happen. I already tried verifying disk

  • I want to buy ebooks for my workers, can I do it in bulk or at discounted price?

    I want to buy ebooks for my workers, can I do it in bulk or at discounted price?

  • Can we improve perfromence if we add the dimensions in LTS

    hi all i have one small doubt , i heard that if we add dimensions in to the fact in LTS(once u double clikc on the LTS in General tab you can find add button from there u can select all the other dimensions which are connected to the fact table , if

  • Ig4icd32.dll problem

    When running PhotoShop CS6 I get the following error message: "The application or DLL C:/WINDOWS/system32/ig4icd32.dll is not a valid Windows image. Please check this against your installation diskette". How do you solve this problem? I have tried re

  • ? re dropdown list in update behavior

    I have a venue table containing a foreign key to a countries table. The insert behavior works OK. The URL link contains the correct countries_id (i.e. 225 for USA). I haven't been able to get the countries or the selected country to appear in the upd