1

I'm trying to debug a program that calls a function in the HashSet class, but I get a message saying: Source not found. I know this is something with not finding the library files. Please, can someone guide me to how I can set it up? Which library files should it be pointing to?

Thank you very much for any pointers.

4 Answers 4

2

Finally got around to doing this awhile ago and I love it.

First you need to download the Java source. I got mine here (look for "Java SE 6 JDK Source Code"): http://www.oracle.com/technetwork/java/javase/downloads/index.html. Download that and stick it somewhere on disk that you can find easily. Keep in mind that the JAR you download has to actually be "installed" somewhere via you agreeing to a license agree (extract it with jav xvf jarname.jar and check the README it contains).

For any JAR file on your CLASSPATH in Eclipse, you can add a source attachment to it to point to its source code. The easiest thing to do is bring up the Package Explorer view. Underneath your project, you should see an item for your Java Runtime Environment (JRE) (mine is called "JRE System Library [JavaSE-1.6]"). Click on the expansion arrow for that and you'll see a list of JARs.

Most all of the Java classes you'll care about viewing are stored in "classes.jar". Right-click on that JAR and select "Properties". In the left hand menu, select "Java Source Attachment". On the right side, click "External Folder" and find the source code that you downloaded and installed and put that folder into the "Location path" field. Hit "Apply" and "OK".

Now you should be able to right click on any built-in Java class in your code and use the "Open Declaration" command or when debugging you will now step into the Java source.

It's a great capability to have. Enjoy!

Sign up to request clarification or add additional context in comments.

Comments

1

HashSet is in JRE Package, so you can download JDK source and attach it into eclipse.
An other way, when you can not find out the source package, you can use JD-Decompiler which has eclipse plugin to decompile your class, it work and show most like original source file.

Comments

1

Choosing a JDK instead of JRE for the runtime environment worked for me!

NOTE:Make sure you have a JDK installed and not only JRE before proceeding.

  • Remove the current system JRE library:

Right Click project -> properties -> Libraries -> Remove current JRE Library.

  • Add other installed library to your project:

In the current dialogue box, click "add library". by default JRE system library is selected, if not, select it and click next. now select "Alternate JRE" and click "Installed JRE". In the new dialogue box, click search and provide the path to your installed Java environments.

  • Finalize

Select an installed JDK, and click OK. Click FINISH and again OK to proceed.

Comments

0

Abdul, The best way is as the others explained to download the sources and attach them in the eclipse.

The EASIEST way would be installing the java decompiler (JAD). Take a look at http://jadclipse.sourceforge.net/install.html. Its explained there in 4 super simple steps :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.