2

I am using maven, when I click some method of JDK from Eclipse, I received the error like "Source not found". I am wondering how to get the source code of JDK from Maven?

user705414
  • 20,472
  • 39
  • 112
  • 155
  • possible duplicate of [Attach the Java Source Code](http://stackoverflow.com/questions/1157597/attach-the-java-source-code) – Thorbjørn Ravn Andersen Jan 01 '12 at 13:28
  • For the record, you can't get the JDK source code from Maven. The JDK is not built using Maven, and that means that Maven won't know where / how to download it. – Stephen C Jan 01 '12 at 13:59

3 Answers3

2

Which class(es) are you attempting to look at? Assuming you installed a JDK and configured Eclipse to use it - and not a JRE, which doesn't contain the src.zip with the source code, this should work in most cases. An exception is for many (if not all) of the com.sun.* classes and others that are only available under the SCSL or the JRL licenses - which is available through a separate download from Oracle, after accepting one of these licenses.

ziesemer
  • 27,712
  • 8
  • 86
  • 94
1

I don't know what Maven has to do with this. You can find the JDK source in the src.zip that comes with your JDK. I don't know how to tell Eclipse to use it: I'm an IntelliJ user. There must be an attach source plug-in or command hidden in there somewhere. Point it at your src.zip and you're in business.

duffymo
  • 305,152
  • 44
  • 369
  • 561
1

If you want to attach the source code of JDK, please reference Attach the Java Source Code

If the source you want to look is from third-party library like spring, you can tell maven to download the source code when you generate eclipse project

mvn eclipse:eclipse -DdownloadSources=true

But not all source can be download unless the source code maven artifact is published to maven repository.

Even more you can download Java doc with this argument when generating eclipse project

mvn eclipse:eclipse -DdownloadJavadocs=true

You can get more info from Maven Eclipse Plugin Link

Hope this will help you.

Community
  • 1
  • 1
donnior
  • 1,055
  • 1
  • 9
  • 12