aspose file tools*
The moose likes Beginning Java and the fly likes Source code of Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Source code of Java" Watch "Source code of Java" New topic
Author

Source code of Java

Hassan Naqvi
Ranch Hand

Joined: May 03, 2001
Posts: 158
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


Always Belive On Logic!!
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You could use winzip to view it. This post should be in the beginner forum though.
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
I am moving this to Java in General (beginner)
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2
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
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
Manjunath Subramanian
Ranch Hand

Joined: Jul 18, 2001
Posts: 236

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
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.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Hassan, do you have WinZip or File Librarian or PKUNZIP on your machine? Any one of those will allow you to extract the file that you want to read.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
<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
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
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hassan, What you are seeing is the source code.


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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.
Hassan Naqvi
Ranch Hand

Joined: May 03, 2001
Posts: 158
So much thanks Jane & Cindy!.
Regards,
Hassan.
 
 
subject: Source code of Java