Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ubuntu openjdk-7 the link "src.zip” is broken

enter image description here

I have installed OpenJDK 7 and it runs well on my Ubuntu 14.04 machine. I want to add Java sources to my Eclipse. When I go to /usr/lib/jvm/java-7-openjdk-amd64 there is a symlink called src.zip but it's broken. How do I fix this? Do I have to manually download sources and add them?

like image 647
samsamara Avatar asked Feb 05 '15 23:02

samsamara


4 Answers

The answer from Alex is correct, as in how it should be. However, for OpenJDK 11 on Ubuntu 18.10 it appears that src.zip has been moved to lib/src.zip so the symlink cannot be resolved.

In addition to the

sudo apt install openjdk-11-source

command, run

echo "(cd /usr/lib/jvm/openjdk-11/; ln -s lib/src.zip)" | sudo bash

to create an additional symbolic link.

like image 189
Thorbjørn Ravn Andersen Avatar answered Nov 05 '22 14:11

Thorbjørn Ravn Andersen


You should do:

sudo apt-get install openjdk-7-source

then the source code will be downloaded under: "/usr/lib/jvm/openjdk-7". The symlink:

src.zip -> ../openjdk-7/src.zip

should work now.

like image 37
Alex Avatar answered Nov 05 '22 13:11

Alex


I downloaded sources from http://jdk7src.sourceforge.net/ and added them to eclilpse. It works fine now.

like image 1
samsamara Avatar answered Nov 05 '22 14:11

samsamara


installing openjdk8 again worked for me in ubuntu 16.04

step1: sudo apt install openjdk-8-source

step2 : attach the source.zip under(Window->preferences-java->Installed JREs->edit java-8-open-Jdk->expand rt.jar->click on Source attachment and attach the src.zip under /usr/lib/jvm/java-8-openjdk-amd64).

like image 1
Prashant Avatar answered Nov 05 '22 13:11

Prashant