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.

Similar Messages

  • 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

  • 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...

  • 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 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.

  • 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.

  • 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.

  • System.out.println crashes wireless toolkit

    I'm using system.out.println calls to create debugging commands to test my application. They mostly work but if I try to print out a lot at once the wireless toolkit crashes.
    This is all on my computer, not on any mobile device.
    The error I get is:
    Exception in thread "Child process stdout copier" java.lang.ClassCastException: sun.java2d.NullSurfaceData cannot be cast to sun.java2d.d3d.D3DSurfaceData
         at sun.java2d.d3d.D3DRenderer.copyArea(D3DRenderer.java:55)
         at sun.java2d.d3d.D3DSurfaceData.copyArea(D3DSurfaceData.java:638)
         at sun.java2d.SunGraphics2D.doCopyArea(SunGraphics2D.java:1986)
         at sun.java2d.SunGraphics2D.copyArea(SunGraphics2D.java:1968)
         at javax.swing.BufferStrategyPaintManager.copyArea(BufferStrategyPaintManager.java:315)
         at javax.swing.RepaintManager.copyArea(RepaintManager.java:1228)
         at javax.swing.JViewport.blitDoubleBuffered(JViewport.java:1604)
         at javax.swing.JViewport.windowBlitPaint(JViewport.java:1573)
         at javax.swing.JViewport.setViewPosition(JViewport.java:1118)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.vsbStateChanged(BasicScrollPaneUI.java:1027)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:1016)
         at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:348)
         at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:285)
         at javax.swing.DefaultBoundedRangeModel.setValue(DefaultBoundedRangeModel.java:151)
         at javax.swing.JScrollBar.setValue(JScrollBar.java:446)
         at com.sun.kvem.toolbar.MainWindow$ConsoleStream.write(Unknown Source)
         at java.io.PrintStream.write(PrintStream.java:430)
         at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
         at com.sun.kvem.environment.StreamCopier.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)Am I doing something wrong or is this a bug in the toolkit?
    Once I get this exception the whole toolkit becomes unresponsive and I have to close it and re-open.

    mydreamgirl, welcome to the forum. Please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    I'm locking this thread now.
    db

  • 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

  • System.out.println in Java Studio Creator 2

    Where do my debugging messages sent to System.out.println go?
    In my other installations of netbeans they went to a window in the IDE but I can't find them with JSC 2.

    you can use System.out.println("") to write something in output (which in web applications it is web application log file)
    also in creator you can use log("") to write something in output which again is the log file.
    you can view the log file by right click on server / view log file

  • Sustitution of System.out.println in Graphical mode

    Dear Sirs:
    I am changing my applications to graphical mode. I would like to know what is the command that substitutes System.out.println in graphical mode. Thanks in advance

    I am not sure exactly what you mean when you say you are changing your apps to graphical mode,
    I assume you will be using Swing?
    If you will be using a gui in the place of a command prompt program, you may need to completely redesign your app (I'm not sure I can help you with that).
    In a Java applet, and application, you can still use System.out.println. It will print to the console while your app runs. I use it pretty often for simple debugging (Although I use JBuilder and the option for the execution Log, if you are in windows and expect the size of the errors to be large an don't have something like this, you may want to run the output into a file using the IO package).
    Hope this helps you,
    Dan Hughes
    Dear Sirs:
    I am changing my applications to graphical mode. I
    would like to know what is the command that
    substitutes System.out.println in graphical mode.
    Thanks in advance

  • 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

Maybe you are looking for

  • Auto Time change, Sound mute and trying to read something before windows 7.

    Dear, I recently bought a MacBook Pro i7. I installed Windows 7 Ultimate through Boot Camp. But after installing i am faceing few problems as listed below: 1: *Automatic Time change* When i am in windows 7 and i switch to Mac OS X the time of my Mac

  • HT3702 My credit card was charged twice for the same purchase. How can this be fixed?

    I purchased an album and it was debited out of my account twice. How can this be fixed?

  • How to use XVID MEPG4 DECODER in labview

    May i ask how to use Xvid MEPG4 Decoder to compress the AVI file. For this decoder have been installed in my computer but the VI(IMAQ AVI2 Get Codec Names)can not list this code name. So may i ask how can i use this decoder in the labview. For this d

  • Error in KM Property Structure

    Hello, When I see System Configuration\Knowledge Management\Global Services I get the warning "Invalid areas: Property Structures" and in Property Structure I get the error "The following configuration objects have some invalid or problematic propert

  • WRT300N v2 problems

    I have a WRT300N v2 which I am using as an AP on a network (containing both wired and wireless clients, mixed Vista 32 and 64 and an Xbox 360) which otherwise uses Windows ICS (on an XP box) to connect to the internet and to supply DHCP services. Wir