7

I'm using IntelliJ and developing code using Java.

When I use "Go to Declaration" [Ctrl+B] to a Java inbuilt feature (e.g. ArrayList), it takes me to that class (e.g. ArrayList.class) and looks a bit like this:

// IntelliJ API Decompiler stub source generated from a class file  
// Implementation of methods is not available

package java.util;

public class ArrayList <E>  extends java.util.AbstractList<E>
implements java.util.List<E>, java.util.RandomAccess,
java.lang.Cloneable, java.io.Serializable {

private static final long serialVersionUID = 8683452581122892189L;
private static final int DEFAULT_CAPACITY = 10;
private static final java.lang.Object[] EMPTY_ELEMENTDATA;
private transient java.lang.Object[] elementData;
private int size;
private static final int MAX_ARRAY_SIZE = 2147483639;

public ArrayList(int i) { /* compiled code */ }

public ArrayList() { /* compiled code */ }

public ArrayList(java.util.Collection<? extends E> es) { /* compiled code */ }

However I seen it on other computer and it actually shows the Java source, not just a comment saying "compiled code".

How do I get this on my computer. Have I set up Java incorrectly?

0

2 Answers 2

10

You should be able to configure it in your project structure (ctrl + alt + shift + S) settings here:

enter image description here

Is your JDK pointing to an invalid Sourcepath?

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

7 Comments

I don't seem to have that src.zip folder? How do I get it. Did I install wrong or do I need to install something additional? Currently there's nothing there for my sourcepath
@YahyaUddin what JDK are you using? OpenJDK? Another one? How did you install it?
I'm using the JDK on the Oracle offical site: jdk1.7.0_40. It's not OpenJDK.
@YahyaUddin are you sure you got the JDK and not the JRE? I downloaded mine the same way.
Thanks a lot! I used the new JDK 8 and it included the src and it work fine. Many Thanks!!!
|
2

I'm on Ubuntu 16.04 and OpenJDK 8. To get the JDK sources I had to separately install an additional package:

sudo apt-get install openjdk-8-source

Thanks to https://askubuntu.com/questions/755853/how-to-install-jdk-sources for the solution.

2 Comments

On arch linux it was 'yaourt -S openjdk8-src'
I also had to go back to IntelliJ and under Settings > Platform Settings > SDKs > select my Java version > Sourcepath add '/usr/lib/jvm/java-8-openjdk'.

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.