tags:

views:

191

answers:

4

How do you install the source for the java libraries in Eclipse?

A: 

WHat do you mean with java source? The java.lang package? Because there shouldn't be a need to "install" them. Creating a new Java Project ( any kind of Java Project) should be enough. Could you describe your problem in more detail?

BernardMarx
+1  A: 

You can do it in the project preferences, but I find quite faster just to ctr+click over a object or class defined in the standard library and then "attach source" in the page that will gently inform you that there are no sources attached.

You then can point to the "src.zip" in your JDK distribution.

fortran
+1  A: 

The way that I do it:

Prerequisite: you have the source downloaded. It comes with the JDK. (src.zip)

  1. Open up a Java file
  2. Ctrl + Click on a class name.
  3. Click on the button that says 'Attach Source'
  4. Locate the src.zip file. (Usually in the JDK install location)
  5. Now you have the source installed!
jjnguy
+2  A: 

This happens automatically if you set up a JDK rather than a JRE.

Normally, when you start eclipse, it sets up the JRE that was used to start eclipse. You'll usually want to override this with a JDK so you get the source. To do this:

  1. First, make sure you have a JDK installed (and not just a JRE)
  2. Start eclipse
  3. Go to Window->Preferences->Java->Installed JREs
  4. Press Add...
  5. Choose "Standard VM" and press "Next..."
  6. Press "Directory...", select the JDK installation directory and press "Ok"
  7. Press "Finish"
  8. Make sure you check the box next to the new JDK
  9. Press "Ok" to finish up

This will set up the source properly for you.

Scott Stanchfield