This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi friends, I hope there must be some resourse of source code of Java.I have look a directory in jdk1.3 named src.But what is procedure of viewing the source code of Java. Regards, Hassan
If you have the src directory already, then you should be able to view the *.java files with any text editor. If you don't have the src directory or it doesn't contain any files, you can expand the compressed file src.jar with the following from the command line: jar -xf src.jar
Hassan Naqvi
Ranch Hand
Joined: May 03, 2001
Posts: 158
posted
0
Thanks Michael. I have got the src.jar file & after using the command u recommend i got src folder.Now the problem is that when i open src\java\io\ByteArrayOutputStream in notepad i got code in very haphazard way.It is not organized it contains @ , boxes, etc... plz. help me. Regards, Hassan
The best way to view the source code is with all the documentations in the source code.So follow this step.. After extracting, you will get to see the different packages under the java package.So to view all the files say in the lang package.. type javadoc *.* at c:\jdk1.3\java\lang\> This will help you in seeing the source code with the documentation
Hope this helps, Manjunath
Hassan Naqvi
Ranch Hand
Joined: May 03, 2001
Posts: 158
posted
0
Hi Manjunath, I have done exactly what u said.Just i made the small changes in path i.e c:\jdk1.3\src\java\lang>.After executing the cmd u mentioned i get a series of statements some thing like this.... Loading source file System.java. Loading source file Thread.java. Loading source file ThreadDeath. Loading source file ThreadGroup. .................etc. But i didn't got any htmsl file or any new file in ...java\lang>.However i tried the same cmd. at this path, c:\jdk12-doc\jdk1.2\docs\api\java\lang> It creats all the coresponding html files.But still unable to see the source code.! Plz. help. me Regards, Hassan.
<pre>/* * @(#)ByteArrayOutputStream.java1.43 00/02/02 * * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */ package java.io;
/** * This class implements an output stream in which the data is * written into a byte array. The buffer automatically grows as data * is written to it. * The data can be retrieved using < code>toByteArray()< /code> and * < code>toString()< /code>. * * @author Arthur van Hoff * @version 1.43, 02/02/00 * @since JDK1.0 */ public class ByteArrayOutputStream extends OutputStream { < snipped></pre>
However, when I use Notepad, I see: /* * @(#)ByteArrayOutputStream.java1.43 00/02/02 * * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */ package java.io; /** * This class implements an output stream in which the data is * written into a byte array. The buffer automatically grows as data * is written to it. * The data can be retrieved using < code>toByteArray()< /code> and * < code>toString()< /code>. * * @author Arthur van Hoff * @version 1.43, 02/02/00 * @since JDK1.0 */ public class ByteArrayOutputStream extends OutputStream { < snipped >
Is this what you see? Perhaps you need to use a different text editor to view the source code.
[This message has been edited by Marilyn deQueiroz (edited October 29, 2001).]
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Hassan Naqvi
Ranch Hand
Joined: May 03, 2001
Posts: 158
posted
0
Sorry 4 replying late.... Cindy i have WinZip installed in my machine. Marilyn when i open c:\jd1.3\srs\java\io>in this directory i open ByteArrayOutputStream(in property it's File Type is Java Source) i got some thing like this... /* * @(#)ByteArrayOutputStream.java1.43 00/02/02 * * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */ package java.io;
/** * This class implements an output stream in which the data is * written into a byte array. The buffer automatically grows as data * is written to it. * The data can be retrieved using <code>toByteArray()</code> and * <code>toString()</code>. * * @author Arthur van Hoff * @version 1.43, 02/02/00 * @since JDK1.0 */ public class ByteArrayOutputStream extends OutputStream { /** * The buffer where data is stored. */ protected byte buf[]; /** * The number of valid bytes in the buffer. */ protected int count; /** * Flag indicating whether the stream has been closed. */ ........................ETC..................................... Still unable to open source code Regards, Hassan
The source code that Sun puts out is fully documented with JavaDoc comments (that were used to create the API that we all know and love). The code is intersperced within the comments.