Issue
When trying to jump to Java API source code (by Ctrl/Cmd+Click) it shows Source not found
and has an option to Attach source...
I'm a mac user, I installed only JDK, and eclipse can find the Java API source code without me setting anything. But for Windows/Ubuntu, even I install only the JDK, it always ask to Attach source...
in the first time. Which I'm tired of telling every single one of my friends how to fix this, because there are so many steps.
So I don't know if I installed Eclipse & JDK (on Windows/Ubuntu) wrongly, or this is normal. And are there any way to install Eclipse and JDK so it could use Ctrl+Click to jump to a readable source code right on the first time?
Note: The JDK is downloaded from oracle.com
(Windows), apt-get install openjdk-8-jdk
(Ubuntu). And Eclipse is downloaded as zip
from eclipse.org
(not the Eclipse Installer because I needed to share through USB)
Solution
In the Eclipse Java IDE the default JRE is set to the JRE that is used to run Eclipse. In Windows, when installing a JDK, a JRE is also installed (e. g. after installing a 64 bit JDK you will have both C:\Program Files\Java\jdk<version>\bin\java.exe
and C:\Program Files\Java\jre<version>\bin\java.exe
). Unfortunately, the JRE is used by Windows by default and therefore by Eclipse by default.
In your case, maybe the easiest way is to add an embedded Java JDK to your Eclipse ZIP to share (this also avoids the need to install Java):
- Create a folder
jre
- Copy everything from a Java JDK installation directory (e. g. installed Windows 64 bit Java JDK: from
C:\Program Files\Java\jdk-9
) into thejre
folder - Add the
jre
folder to your Eclipse ZIP to share
Answered By - howlger
Answer Checked By - Katrina (JavaFixing Volunteer)