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?

  • 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 8: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 8: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 9:37

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:

  • 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 9: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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.