2

I want to know where are the java API's stored. I use openJDK 7. I want to edit some of the code of a class to suit my needs and therefore I want to know where are these API's stored. Can anyone please answer this question?

Jorge Castro
  • 71,754
Pranit Bauva
  • 1,091
  • 1
    So you're looking for the source code, not the API documentation? Wouldn't it make more sense to just extend the class in question? – geirha Jun 30 '12 at 08:03
  • I want to change the source code only .... i know to extend but i want to change the source code – Pranit Bauva Jun 30 '12 at 08:05
  • 1
    Do not edit code in the Java API - it will make your installation non-standard. Instead learn how to create subclasses and override the methods you want. – Thorbjørn Ravn Andersen Jun 30 '12 at 09:37

1 Answers1

2

To get the source code, run (as a regular user, not root)

apt-get source openjdk-7-jre

It will download the source tree used to generate all the openjdk-7 packages. It downloads it to your current directory, so you may want to run something like mkdir -p ~/src && cd ~/src first.

The compressed archive jdk-dfsg.tar.gz at the root of the source tree appears to contain all the standard classes.

You might need to enable source code repositories:

geirha
  • 46,101
  • its coming as "E: You must put some 'source' URIs in your sources.list" Can you please suggest some links ?? – Pranit Bauva Jun 30 '12 at 09:45
  • @PranitBauva make sure each deb-line in /etc/apt/sources.list also has an identical (apart from the first word) deb-src-line. By default, all the standard repositories should have this, so I'm guessing you've modified your /etc/apt/sources.list at some point. – geirha Jun 30 '12 at 10:01