How does System.out.println(). Work inside src.zip file !

Hello guyz,
I was just wondering how System.out.println() worked so i opened up the src.zip file and checked the source code. But could not understand it. As written i remember
"out is an object encapsulated in the System class."
Thats ok. But i could not understand the code.
    public final static PrintStream out = nullPrintStream();
    private static PrintStream nullPrintStream() throws NullPointerException {
     if (currentTimeMillis() > 0) {
         return null;
     throw new NullPointerException();
    }Also when i ran the DJ Decompiler it decompiled it to this:
public class One
     public static void main(String args[])
          System.out.println("hello world");
import java.io.PrintStream;
public class One
    public One()
    public static void main(String args[])
        System.out.println("hello world");
}Also, why does it need to import PrintStream ?

Peter__Lawrey wrote:
I was just wondering how System.out.println() worked so i opened up the src.zip file and checked the source code.This value is a place holder. This value is changed as soon as enough of the JVM is initialised for printing to work.
Also, why does it need to import PrintStream ? It doesn't, but it is used in the code so DJ is including it just in case.Sorry,
But i don't understand at all.

Similar Messages

  • Which toString() method does System.out.println() call?

    Which toString() method does System.out.println() call? I know that if I did something like System.out.println( new myClass() ) that the toString being called would be that of the myClass class.
    My initial thought about this was that System.out.println() is the equivalent of System.out.println( new Object() ) but I remember trying that in a test program and it gave me a myClass@some_hash_code type of message when adding the new Object() part within the System.out.println().
    Could someone please tell me which toString the System.out.println() statement calls? Also, it would be great if an elaboration follows :).
    Any input woudl be greatly appreciated!
    Thanks in advance!

    s3a wrote:
    My initial thought about this was that System.out.println() is the equivalent of System.out.println( new Object() ) Huh?
    In one method call you pass no parameters in the other method call you pass one parameter. How could you possibly think that they would do the same thing?
    Could someone please tell me which toString the System.out.println() statement calls? Also, it would be great if an elaboration follows :).Yes. The toString of the class of the object which you pass to the method. If that class does not have a toString method it uses the toString method it inherits from the parent class. If the parent class does not have a toString method it uses the one inherited and so and so on all the way up to the Object class.

  • Why doesn't System.out.println work for Palm?

    In my Java code,
    how come I don't see any output on my screen (Palm Vx) when I try this?
    System.out.println("Hello World");
    Where is the output really going to???

    Hi,
    On POSE (Palm OS emulator), the System.out.println() method output is a file called STDOUT.txt, filed in some directory of the emulator.
    On the eal device, I think theres no output for system.out.println().
    Ricardo

  • System.out.println statements inside my session beans

    I have some System.out.println statements inside my session beans to track some error conditions. I would like to know where this output will be printed. Is there any text file I should look for or start up any console to see the output.
    I am running iPlanet SP3 test drive edition iPlanet Web Server 4.1 on WIndows NT machine.

    Hi,
    These statements will be printed on the kjs logs file. To view them, go to control panel-> services-> select the iPlanet Application server and click "start up" tab. Check " allow this sevice to interact with the desk top" in the service window that has been popped up. Restart the iPlanet Application server.
    View the kjs window. All your System.out.println statements will be printed out there.
    If you have any further queries please get back to the forum.
    Thanks for visiting our web forum,
    Rakesh.

  • System.out.println()'s inside implementation

    Hello,
    We all know the System.out.prinltn() API. But I want to know the inside implementation of System.out.println() API. Where can I get this implementation?
    Furthermore, can anyone explain concretely about how to implement System.out.println()? Can you tell me in a great detail?
    JohnWen604
    21-June-2005

    I just cannot understand what is the magic behind
    d that one API can control the hardware(i.e. control
    the screen to print one "simple" sentance). Do youIt's called "native OS methods". And you're not controlling anything, the graphics driver does. You're just asking the OS to ask the driver to ask the graphics card to send the appropriate signals.
    think that is just just the magic of our grand new
    computer? So If I can fully understand how the
    hardware is controlled by the Application Program, I
    will be more sensible in writing software. Just likeI doubt that. The more sensible way would be to stick to a useful level of abstraction and good design.
    you know the IC's inner structure if you want to be
    an qualified Electronic Engineer. Do
    you think so?No.
    Besides, from some OS books I know that
    w that Application program written in Java will
    become some OS commands that is ready for going
    through the OS's command processor. I just do not
    understand how that primitive Java code is written
    which is OS command and can tell hardware(screen) to
    print something. Do you know what that primitive Java
    code is?-- The primitive Java code that is a OS
    command to tell screen to print something. The
    primitive java code 's examples are "+", "for",
    "while", "private". The primitive java code does not
    mean API.No. It's called "instructions".
    What you said about setOut0(), I think
    setOut0() is simply an API. Do you know the
    implementation of this setout0() API? There must be
    implementation and there must be the primitive Java
    code. Do you agree with me?No. It's N-A-T-I-V-E. No Java code. Nowhere. Just C++ or whatever.

  • Where does System.out.println go?

    Hi Everyone: I know I've seen this topic before, but I'm still having some trouble. I would like to debug my EJBs, and so I've added some System.out.println statements to them. Where does that go? I've looked at the defaultTrace.trc files in the
    C:\usr\sap\P48\JC00\j2ee\cluster\server0\log
    folder, and haven't found any of the text that I think I am writing. I appreciate any guidance! Ian.

    Hi lan,
    I was facing the same question earlier, and now I think I have figured out one possible answer. Actually, where the System.out.println goes is up to the Server Admin to config. There is a default SYSTEM.OUT log controller ( under location controller side) pre-defined to cater for all System.out.println(). All the System.out.println() output is considered as INFO type log message. However, this default SYSTEM.OUT controller is not assigned with any real log destination, thus, we cannot find the output anywhere.
    If you goes to the log configurator (using Visual Admin), you can locate this SYSTEM.OUT controller , and add in a default (Anonymous) destionation for it . (you need to toggle on the advance edit mode from the top menu , then you can add modify the destination settings of a Controller).
    For Anonymous destionation, the println() output will sure go to the defaultTrace.trc (better view it using Log Viewer, instead of viewing it from the log file ).
    Or , you can define a separate file (e.g. c:\temp\myStd.log ) as the log destination ..
    Last but not the least, you need to set the ForceSingleTraceFile setting from 'YES' to 'NO' , then you can see your "myStd.log".
    To change the ForceSingleTraceFile , go to Visual Admin, J2EE server --> Kernel --> LogManager.
    Hope you find the above useful.

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

  • Does System.out.println() has a limit ?

    I have this little program that permuates strings
    public class PermutationGenerator
         private void perm(String s, String prefix)
              int length = s.length();
              if (length== 0)
              System.out.println(prefix);
              else
                   for (int i = 0; i < length; i++)
                        perm(s.substring(0, i) + s.substring(i+1, length), prefix + s.charAt(i));
         public void printPermutations(String s)
              perm(s,"");
         public static void main(String[] args)
         new PermutationGenerator().printPermutations("word") ;
    The problem is that when I use a longer string like "longword", I only get 299 different permutations printed. Even if I use an "evenlongerword", I will get 299 permutations. Is this because of java? Because I can't see any errors in my code.

    You probably need to change your command prompt
    screen buffer size. Sounds like you have the height
    set to 300 lines. You can also redirect your output
    to a file to see everything.Very well spotted! The voice of experience!

  • What does System.out.println("Hello world!");  when System.console()=null?

    Hello,
    the code below:
    if(System.console()!=null)
                outStream=System.out;
            else
                outStream=new PrintStream(new FileOutputStream(new File("BasicCardReaderManagerLog.log")));
            outStream.println(System.currentTimeMillis());
            outStream.println(System.out.toString());produce the following output, in the BasicCardReaderManagerLog.log file:
    1249991451796
    java.io.PrintStream@190d11
    So it looks like System.out is valid and usable, however, since the application as no console, where I can see the output ???
    Precision: I get this situation in the main function of a console application which I launch using Process.Start. Is there any way to get a console by this mean ?
    Best regards,
    Sebastien

    Based on [http://forums.sun.com/thread.jspa?messageID=10790600#10790600|http://forums.sun.com/thread.jspa?messageID=10790600#10790600]
    import java.util.*;
    public class Java {
         public static void main(String[] arg) throws Exception {
              String[] cmd = { "cmd.exe", "/C", "start", "java.exe" };
              List<String> l = new ArrayList<String>(Arrays.asList(cmd));
              l.addAll(Arrays.asList(arg));
              cmd = l.toArray(cmd);
              Process p = Runtime.getRuntime().exec(cmd);
    }

  • Where does System.out.println("") send info?

    Under normal java execution it goes to the java console... where does it go when running a servlet under Tomcat on localhost?

    Output is written to the log file whose location is specified in server.xml. The default is the /logs directory under the tomcat root.

  • Urgent: Redirecting System.out.println to more than one place

    Hi All,
    I want to divert all my System.out.println() statements to a Log file as well as on to the screen.
    But only one of the 2 options actually works.
    So if anyone can suggest me some ways I will appreciate very much.
    My code looks something like this:-
    if (m_filename != null) {
    try {
    FileOutputStream fos = new FileOutputStream(m_filename);
    PrintStream ps = new PrintStream(fos);
    System.setOut(ps);
    System.setErr(ps);
    //This code Added for Printing Onto Screen But it does not work
    Stream ps1 = new PrintStream(System.out);
    System.setOut(ps1);
    System.setErr(ps1);
    } catch (IOException ioe) {
    System.out.println("Could not create log file " + m_filename + " because " + ioe);
    As far as logging onto file is menat it works when i set it but printing onto screen does not.
    How can i achive it
    Thanks
    Raj

    Hi,
    You are right but in my current scenario i cannot incorporate this log4j because my application is using some other framework and I am just trying to override this frameworks loggig behaviour so that it logs to both a log file as well as on to the screen.
    Here is the code that this framework uses for logging and i am simply overriding it to do the reqd thing but its not working for me:-
    * Resets the System's out and err OutputStreams to the Launcher's
    * own ThreadedOutputStream, so that output from different threads
    * can be tracked efficiently.
    protected void setOutputStreams() {
         if (scInfo.size() <= 1) {
    // don't need Threaded handling with one thread
    if (m_filename != null) {
    try {
    FileOutputStream fos = new FileOutputStream(m_filename);
    PrintStream ps = new PrintStream(fos);
    System.setOut(ps);
    System.setErr(ps);
    //Added for Printing Onto Screen
                             PrintStream ps1 = new PrintStream(System.out);
    System.setOut(ps1);
    System.setErr(ps1);
    } catch (IOException ioe) {
    Debug.fatalError("Launcher.setOutputStreams","Could not create log file " + m_filename + " because " + ioe);
    else {
    Debug.information("Launcher.setOutputStreams","Initializing ThreadedPrintStream");
    if (m_filename == null) {
    System.setOut(new ThreadedPrintStream(System.out));
    System.setErr(new ThreadedPrintStream(System.err));
    else {
    PrintStream out = new ThreadedPrintStream(m_filename);
    System.setOut(out);
    System.setErr(out);
    //Added for Printing Onto Screen
    System.setOut(new ThreadedPrintStream(System.out));
    System.setErr(new ThreadedPrintStream(System.err));
    Debug.information("Launcher.setOutputStreams","ThreadedPrintStream initialized.");
    Thanks
    Raj

  • System.out.println() fn in j2me

    Hello Everbody,
    can anyone plz tell that if i write down System.out.println() in my j2me app(in many classes and and at many places) and use it on mobile that app, does it slows down the app after sometime,bcz i m running the app it goes good for half anhour or so, but slows down after that and gets slower and slower does "System.out.println()" affect it or do thread creates the prob,plz clearify it, if any one knows,
    Thanks

    ask it in the j2me forum
    http://forum.java.sun.com/forum.jspa?forumID=76

  • Where to see the System.out.println() messages

    I deploy my application in Oracle9ias . I have some System.out.println() statements in java class files.
    When I run the application I need to know where I can see those println() statements.

    The Member Feedback forum is for suggestions and feedback for OTN Developer Services. This forum is not monitored by Oracle support or product teams and so Oracle product and technology related questions will not be answered. We recommend that you post this thread to the Application Server-General forum. The URL is:
    Oracle Application Server - General

  • How does a CIN code works in LabVIEW?

    hi..can any one explain as to how a CIN code (written in c/c++) works in LabVIEW.Do we have to import the c/c++ file too when we import the respective VI? How does the CIN code work in an exe file without having to load the C/C++ code?

    When you create the VI that calls the CIN you load the binary object code into the code interface node itself and it's stored as part of the VI. Hence you don't need to include anything special in your build. Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to get the entries in a jar/zip file contained within a jar/zip file?

    If I want to list the jar/zip entries in a jar/zip file contained within a jar/zip file how can I do that?
    In order to get to the entry enumeration I need a Zip/JarFile:
    ZipFile zip = new ZipFile("C:/java_dev/Java_dl/java_jdk_commander_v36d.zip");
    // Process the zip file. Close it when the block is exited.
    try {
    // Loop through the zip entries and print the name of each one.
    for (Enumeration list =zip.entries(); list.hasMoreElements(); ) {
    ZipEntry entry = (ZipEntry) list.nextElement();
    System.out.println(entry.getName());
    finally {
    zip.close();
    Zip file "java_jdk_commander_v36d.zip" contains two zip entries:
    1) UsersGuide.zip
    2) JDKcommander.exe
    How to list the entries in "jar:file:/C:/java_dev/Java_dl/java_jdk_commander_v36d.zip!/UsersGuide.zip"?
    The following code:
    URL url = new URL("jar:file:/C:/java_dev/Java_dl/java_jdk_commander_v36d.zip!/UsersGuide.zip");
    JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
    zipFile = (ZipFile)jarConnection.getJarFile();
    would point to "jar:file:/C:/java_dev/Java_dl/java_jdk_commander_v36d.zip", which is no help at all and Class JarURLConnection does not have an enumeration method.
    How can I do this?
    Thanks.
    Andre

    I'm not sure I understand the problem. The difference between a zip and jar file is the manifest file; JarFile is extended from ZipFile and is able to read the manifest, other than that they are the same. Your code
    for (Enumeration list =zip.entries(); list.hasMoreElements(); ) {
    ZipEntry entry = (ZipEntry) list.nextElement();
    System.out.println(entry.getName());
    }is close to what I've use for a jar, below. Why not use the same approach? I don't understand what you're trying to do by using JarURLConnection - it's usually used to read the jar contents.
    String jarName = "";
    JarFile jar = null;
    try
        jar = new JarFile(jarName);
    catch (IOException ex)
        System.out.println("Unable to open jarfile" + jarName);
        ex.printStackTrace();
    for ( Enumeration en = jar.entries() ;  en.hasMoreElements() ;)
        System.out.println(en.nextElement());
    }

Maybe you are looking for

  • I REGRET CHOOSING THE 5800XM

    I know some of you are in love with it but there's a whole lot of others who'll agree with me on this one. My 5800XM is one of the worst in history, what happened to customer satisfaction? The fone crashes a lot, the photo gallery shows no photos but

  • [VB, CS3] How to place images using wildcards in filenames

    Dear all, Can anyone think of a way to place an image using a wildcard in the filename? I can place the image fine if the complete filename is known, but what if the filename changes from day to day? - eg it could be House1234.tif for one document th

  • Database Configuration Assistant Failed

    On Windows 2000 8iEE 8.1.7 9iAS EE 1.0.2.1 Same Machine I'm facing a problem with Cache Database Configuration Assistant. By the time I was installing 9iAS EE, the Database Configuration Assistant show up and It get connected properly to the origin d

  • PRC returns same FolderID as ParentFolderID in simple test

    Greetings, I have been trying to learn the PRC API and encountered an interesting artifact. Basically I get the same FolderID as ParentFolderID for community objects when I invoke a query. Now, I might be dumb, but I am using the very code out of Plu

  • Why does the App Store updates finish with (NSURLErrorDomain error 1 1012.)

    Why does the Mac App Store updates finish with (NSURLErrorDomain error 1 1012.) rather than ever finding any updates?