• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Source code of Java

 
Hassan Naqvi
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use winzip to view it. This post should be in the beginner forum though.
 
ersin eser
Ranch Hand
Posts: 1072
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving this to Java in General (beginner)
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1820
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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).]
 
Hassan Naqvi
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hassan, What you are seeing is the source code.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So much thanks Jane & Cindy!.
Regards,
Hassan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic