You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac系统下Eclipse导入JSoup出现Source Not Found错误的解决求助

Fixing "Source Not Found for Referenced Libraries: java" in Eclipse (Mac)

Hey there! No worries about terminology—we’ve all been stuck on these Eclipse setup quirks when starting out. Let’s walk through exactly how to resolve this issue:

First, a quick explanation: This error pops up because Eclipse can’t find the source code files for the core Java libraries (like the java.lang or java.util packages) that your project uses. When you try to look into these classes or debug, Eclipse asks you to "attach a source" to show you the actual code. Here’s how to fix it on your Mac:

Step 1: Locate your JDK’s source file

Mac stores JDK installations in this default directory:
/Library/Java/JavaVirtualMachines/

Inside this folder, you’ll see a folder named something like jdk1.8.0_351.jdk (the version number will vary). Navigate into it, then go to Contents/Home—here you’ll find src.zip, which is the compressed file containing all the core Java source code.

Step 2: Attach the source to Eclipse’s JRE System Library

  • Open your Eclipse project, expand the Referenced Libraries section in the Project Explorer.
  • Find the entry labeled JRE System Library (this is the "java" library the error is referring to), right-click it, and select Properties.
  • In the properties window, switch to the Source Attachment tab.
  • Click External File..., navigate to the src.zip file you found in Step 1, select it, and click OK.
  • Close the properties window—Eclipse will now load the core Java source code, and the error should disappear.

Bonus: Check JSoup’s source (if needed)

If you ever see a similar error specifically for JSoup (not the core Java library), you can fix it the same way:

  • Download the JSoup source package (named something like jsoup-1.17.2-sources.jar from the official JSoup build)
  • Right-click the JSoup jar in Referenced Libraries, go to Properties > Source Attachment, and attach the sources jar file.

That should get you sorted! Let me know if you hit any snags finding the JDK directory or src.zip file.

内容的提问来源于stack exchange,提问作者axu08

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 18:23:15