Is it possible not to use System.out.println?

Hi guyz,
Can anyone tell me if there is a way not to use System.out.println but produce the output on the command prompt? I need to add two numbers which are accepted through the args(command prompt). I have to add them and show them on command prompt without using System.out.println. Can ANYONE HELP?

Hi guyz,
Can anyone tell me if there is a way not
s a way not to use System.out.println but produce the
output on the command prompt? I need to add two
numbers which are accepted through the args(command
prompt). I have to add them and show them on command
prompt without using System.out.println. Can ANYONE
HELP?Why can't you use System.out.println? What's the reason?
Kaj

Similar Messages

  • Using System.out.println

    I am migrating to a Sun server using Iplanet 6. I was on a HP-UX 11.0 server using Iplanet 4.2. I am having problems with two things. First, to get debugging information we use System.out.println in our servlets and JSP's. To get the output, we would redirect our start script when starting the server to a file. The trouble is now there is no output when using System.out.println.
    My second problem is request parameters. I do not always appear to get my request parameters in JSP's that use frames. The outer frameset uses request.getQueryString and then passes the query string to the two frames in the frameset. However, I do not appear to be doing that now.

    Instead of using System.out.println, try looking into the ServletContext.log method.
    I hope this helps with your first question.
    -Richard Burton

  • Multiple Threads Using System.out.println...

    i have a client server app and each client that connects to the server has its own thread.
    i am running the server on a pc using windows xp and to run it i just use a bat file which uses cmd.exe and my output using System.out.println prints out in the cmd.exe.
    each of my threads is using System.out.println to send debug info and outs quite often.
    after the screen fills a scroll bar appears at the right and you can scroll back to see past output.
    my app is all running ok but when i had a ton of output coming in all at once i tried to scroll back to see the older output and realized that if i click down on the scroll bar and fight the new input it freezes my server app. then when i release it it continues lol.
    it made me wonder if output from multiple threads when there are many all at once (say 20 or 30 threads all outputing at the exact same time) could cause a slow down or effect the performance of the server?
    i use a debug variable so i can just turn this output 100 % off except for critical errors so there would be no output but i am just curious as to whether or not it may be causing problems when its on.

    That's not a performance issue, I guess System.out.println() simply gets blocked by the console while you're scrolling and thus your app stalls, until you stop doing that.
    Maybe you should look into logging.

  • Printing on chars on the same line using system.out.println

    i have the following string:
    String msg = "This is a message brought to you by one and the only";
    msg.toCharArray(); //converted to a char array.
    i've written a loop which goes through each of the char elements
    and puts it in it's own array:
    int i = 0;             
    while (i < msg.length)
                    char[] test = {msg};
    System.out.println(test);
    the problem is system out println prints out each of the elements on seperate lines is
    it possible to have them in one line to reform the original string?

    No exactly sure what you are trying to do. Does this
    help?
    String msg = "This is a message brought to you by one
    and the only";
    char[] test = msg.toCharArray();
    System.out.println(test);
    not really because i want to convert the string to a char array and then reform it in another char array and then i can choose which elements i want included and not to be so that it can be printed on the same line. I can do it the following way:
    char[] test = {test[0], test[1]]};
    but say i want all the letters containing the chracter T (and again i can use the above solution and select the elements from the string but i don't want to hardcode it, say the string changes etc) in the test array so then i thought of writing a loop:
    while (test[i] == 'T')
    char[] test2 = {test[i]};
    System.out.println(test);
    i++;
    but it puts each T in a new line...

  • Using System.out.println() in Scrapbook

    I am working through some tutorials on formatting numbers:
    http://docs.oracle.com/javase/tutorial/java/data/numberformat.html
    I am trying to use scrapbook. I can't seem to get the result I am wanting from System.out.println("Hello world")...I get null. To be specific I am trying to inspect:
    int i = 461012;
    System.out.format("The value of i is: %d%n", i)In this case I get:
    java.io.PrintStream@46b372
    Something tells me that System.out.format can't work in a scrapbook. Is there a way without writing a main and running as java?

    It seems that the format method returns the PrintStream (allowing you to chain method calls), and the return value is being printed.
    You would get the output you're looking for, if you use the String.format() method, since that'll return the formatted String.

  • How use system.out.println with a Java Swing Applet?

    Hi guys,
    I was just wondering what can I use to view output on the Java console with a Java Swing Applet?
    At the moment I'm using a JTextArea within the Applet for debugging but I want output to appear in the browser java console but system.out.println doesn't work.
    I'm viewing the Swing Applet on Netscape 4.7 browser.
    Any ideas?

    System.out.println()s work fine! I'm guessing that your problem is that you are looking at the wrong console window!
    You're using the Java Plug-in, right? On Windows, go to your Control Panel and double click "Java Plug-in". You should find a checkbox option to "Show Java Console" - make sure this is checked. Next time you fire up you JApplet, you should see a Java Console window popup.
    Hope this helps!

  • Using System.out.println or System.err.println

    Hi All,
    I've a Web Dynpro project which uses a simple java helper class.
    The java class has 'try catch' statements.
    When I'm in 'catch' I want to display an error message on the screen.
    I know that System.err.println writes the message in the defaultTrace.trc log file in the server but as a developer I don't always have access to the server.
    Is there an option to display the error message on the screen with some kind of response object? (I cannot use wdComponentAPI.getMessageManager.reportSuccess in my helper class)
    Thanks,
    Omri

    Hi Omri,
       It's not true that you cannot use the MessageManager in your helper java classes. Here's how you can do it:
    1. Create a java class in the src directory of your project and in the same packeage as your project. I think you have already done this. Let's say the class is called HelperClass.
    2. Declare a public variable of type com.sap.tc.webdynpro.progmodel.api.IWDMessageManager. Call it say, msgManager. The import will be added automatically.
    3. In the wdDoInit() of your WD write something like:
    HelperClass helperObj = new HelperClass();
    helperObj.msgManager  = wdComponentAPI.getMessageManager();
    4. Then when you catch the exception in your helper class, do a simple reportException().
    Regards,
    Satyajit.

  • How to print to console with out using system.out.print

    Hi All
    Is it possible to print the text to console with our using System.out.println(). i done as follows but i does not worked
    import java.io.*;
    import java.util.*;
    public class myclass
         public static void main(String[] args)
              BufferedWriter br = null;
              try {
                   br = new BufferedWriter(new OutputStreamWriter(System.out));
                   br.write("Myclass123",0,10);
              } catch (Exception io) {
                   io.printStackTrace();
    so it will be appretaible if any body helps me in solving this question

    i am using sysstem.out to specify that out put
    generated should be pumped to console inted of file.
    i mean system.out will lead to the console. thats why
    i used that. as Either I have no idea what you are talking about, or you have no idea what I am talking about when I refer to writing to File "con".
    suystem.in means keyboard.Actually, it means "the system's standard input stream, wherever it may come from".

  • 32-bit JDK 7 System.out.println not working in IDE

    Hi folks,
    I have a 64-bit Windows 7 OS.
    Due to 3rd party library/jar dependencies, i had to install the 32-bit Java JDK 1.7 and Eclipse IDE.
    I also installed NetBeans.
    So i have a 64-bit OS and am running 32-bit Java JDK/JRE & IDEs.
    The problem I am having is that my program's System.out.println("...") statements are not outputting strings to either IDE debug console.
    Executing the compiled program from a command line/prompt produces the expected string output.
    The basic "Hello, World" program is enough to cause this behaviour to start occurring.
    I have not manually / intentionally changed any IDE-specific Debug Console or Windows environment settings.
    One caveat: This same environment has worked successfully in the past ?! Yes, this is one of those "..it worked last week & yesterday and today it isn't and i swear i didn't do anything..." issue.
    Thoughts ?

    Thanks for the reply.
    The 64-bit versions of Java & Eclipse were installed first.
    When i discovered I had to use the 32-bit versions, i un-installed the 64-bit ones & installed the 32-bits.
    Even after that initial un-install 64-bit/install 32-bit process, it was working.
    I have also been installing the Windows 7 64-bit OS updates when i am informed of them.
    I'm not sure if any of these would affect how the Eclipse / NetBeans IDEs behave.
    Behaviour has been inconsistent.
    Initially it was always working.
    But over the past several days, it has been working less and less.
    I don't have any large data structures.
    This isn't a large complicated program, couple hundred lines, so i highly doubt that i'm doing anything to the resources, but something has changed.
    The main project I am working on takes command line parameters, does some initial processing, produces output using System.out.printlns [SOP] then depending on the parameters, branches into 2 different processing paths, let's call them A & B. Each of these processing paths also use SOPs. When i run the program in the IDE going thru path A, sometimes the initial SOP statements will work and the SOP statements specific to path A will also work. If i immediately change the parameters to go thru path B & re-run it, not even the initial SOP statements before the branching decision work.
    I've tried doing System.flush()s too - no affect.
    I haven't tried the re-direction option to a file option you mentioned yet.
    It always works from a command prompt - that is telling me that the Java SOPs are working properly, correct ?
    Inside an Eclipse or NetBeans IDE, SOP output to the debug console is inconsistent.
    Running from a command prompt, the SOPs always work.
    It'd help to know if this an IDE issue, a Java issue, a Windows 7 issue so i can narrow down where to try and correct the situation.
    I have a Windows XP VM set up, i'll try running the program there and see if there's a difference.
    Thanks for your reply.

  • Tomcat Servlet: System.out.println in servlet not printing to catalina.out

    Hello friends ,
    When i m using System.out.println() in servlet its o/p should come in catalina.out but its not coming plz help me....one thing more can we replace exixting catalina.out file with new one...
    please Help me soon.
    Thanks

    go to[u] TOMCAT_DIR/config/server.xml.
    Open this xml file and find something like <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="catalina_log." suffix=".txt"
                  timestamp="true"/>and
    <Logger className="org.apache.catalina.logger.FileLogger"
                     directory="logs"  prefix="localhost_log." suffix=".txt"
                timestamp="true"/>You can change the log file name to another one.
    It's much better to use a logger tool like log4j (http://logging.apache.org/log4j/docs/download.html) then using a System.out.println()...
    hope that helps

  • Why System.out.println not PrintStream.println ?

    Hi, just a beginner question
    I just wonder why should we use System.out.println, not PrintStream.println ?
    the field out in the System class is the instance of PrintStream class, isn't it?
    So why don't we just use the PrintStream class directly?
    Thanks..
    Edited by: riff_almighty on Oct 27, 2007 3:27 AM

    According to the api:
    A PrintStream adds functionality to another output stream, namely the ability to print representations of various data values conveniently. Two other features are provided as well. Unlike other output streams, a PrintStream never throws an IOException; instead, exceptional situations merely set an internal flag that can be tested via the checkError method. Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.
    So there is nowhere mentioned about the PrintStream associated with the user console. System.out is the one instance of PrintStream which is associated with the console...
    Also println() is not a static method and cant be called upon the class...
    Edited by: VijayBabu on Oct 27, 2007 12:51 AM

  • How to replace System.out.println() using templates

    can you give the complete code for my problem which is given below.
    package include;
    public class P
    public static cout(int a)
    System.out.println( a);
    public static cout(int a,int b)
    System.out.println(a + b);
    // like this i need to write to accept parameters from the class. which is importing this package
    for some more examples
    public static cout(int a,String s)
    System.out.printn(a +s);
    and many more type i.e. all types of arrangements of datatypes
    the above is the package called "include" Now Iam Importing the package in the class Hello:
    import include.P;
    public class Hello
    public static void main(String args[])
    int i=10;
    float f=12.23;
    String s="hello";
    P.cout(i,f); //cout is the static method of package(include) class " P"
    P.cout("welcome",s)
    // like this I want to send any type and any no of arguments as the System.out.println()
    will handle.
    My aim is to replace the System.out.println() with P.cout() which can be achieve in my idea by calling the static method ( such as cout() ) which internally use System.out.println() method. I am facing problem in achieving this because we donot know which type and how many parameters he will send .
    My task is we have to create a method which will accept any no.of arguments and is of any type.I think this can be done BY USING TEMPLATES.
    So please understand my problem and send me reply.I am waiting for your reply.
    thank you.

    Although I am not sure why you are doing this, if you really are trying to code a replacement for System.out.println then:
    out is a PrintStream and the println methods of PrintStream have the following signatures:
    void println()
    Terminate the current line by writing the line separator string.
    void println(boolean x)
    Print a boolean and then terminate the line.
    void println(char x)
    Print a character and then terminate the line.
    void println(char[] x)
    Print an array of characters and then terminate the line.
    void println(double x)
    Print a double and then terminate the line.
    void println(float x)
    Print a float and then terminate the line.
    void println(int x)
    Print an integer and then terminate the line.
    void println(long x)
    Print a long and then terminate the line.
    void println(Object x)
    Print an Object and then terminate the line.
    void println(String x)
    Print a String and then terminate
    So you should only need to create corresponding methods.

  • Compile error when using System.out

    Hello,
    I have a static part (declarative, comes within <%! %>) inside a jsp. When i use System.out.println inside this, it throws me error. Let me know what is the reason for the same.
    Thanks, Aravinth

    Hi Aravinth.
    You it self told that <%! %> is a declarative statement then how you can give a output statement.
    <%! %> It includes only declarative statements.
    And also System.out.println can't be used in Jsp since it is a implicit object.out is already declared is jsp as implicit object.You can use it as out.println();in <%%>.
    Try to avoid scriplets in jsp.
    regards,
    satheesh kannan

  • Is it possible to overide System.out.println()....

    Hi all,
    I have a program which uses System.out.println() a lot. As the whole program needed to be in GUI form, I have to abbandon the console window and print all my outputs to a special text pane which I have already created and tested.
    My problem is, is there a way for me to keep my System.out.println() statements as they are and print the outputs to my text pane instead of printing it to the console?
    Can I use some kind of overriding of System.out.println()? If so can anybody tell me how to do it?
    Thank you all in advance

    Hi again guys,
    I managed to get the system.out working. Thanks again. But I was trying to do the same to system.in using a class that inherits from InputStream and failed, can you help me out again pliz.
    following is a simplified version of the code. problem I have is that the input I get on readButton click(see the code) is always -1. The code doesn't wait for user input . How can I correct this. please help Thanx
    public class Main() implements ActionListener
        JTextPane textPane;
        JButton readButton;
        public Main()
                this.initGUI();
                Console myConsole = new Console(this.textPane);
                System.setIn(new myInputStream(myConsole));
        private void initGUI()
               this.textPane = new JTextPane();
               this.readButton = new readButton();
               this.readButton.AddActionListener(this);
                //code to create the GUI and show the textPane
               //follows
         public void ActionPerformed(ActionEvent e)
                 try
                             int keyCode = System.in.read();
                     }Catch(Exception e)
                 System.out.println("Pressed Key Code is " + keyCode);          
         public static void main(String[] args)
                   new Main();
    public class Console extends KeyListener
         JTextPane textPane;
         int pressedKey = -1;
         public console(JTextPane textPane)
                 this.textPane = textPane;
                 this.textPane.addKeyListener(this);
        public void keypressed(KeyEvent e)
                this.pressedKey = e.getKeyCode();
       public int read()
               return this.pressedKey;
    public class myInputStream extends InputStream
                Console console;
                public myInputStream(Console console)
                       this.console = console;
                public int read()
                       return this.console.read();
    }

  • Is there a way to force System.out.println to run when called

    I working on my first threaded program and having a hard time debugging. I've used System.out.println to let me know what's going on but due (I assume) to the nature of threads the output is not sequential. Is there a way to force println to execute immediatly so that they show up in the order they were called?
    Thanks --- Mike

    mjs1138 wrote:
    endasil, Thanks for the reply. I'm currenlty running the program from within the NetBeans IDE. It is the output displayed by in NetBeans "output" that I'm looking at.
    --- MikeI don't use Netbeans, but I would guess that it too pipes Standard Out and Standard Error to the same console. You didn't address my comment. Are you printing to System.err as well? This happens implicitly if you use Exception.printStackTrace(), for example.

Maybe you are looking for