How to attach a different source jar?

I'm not using maven or anything, just plain Intellij.

I've opened a binary jar and it had the "Attach sources" link. I selected a jar file and attached it. After opening the source, I realized I have attached the wrong jar file.

However IntelliJ doesn't seem to allow me to change it. There are no options in the GUI. I've manually changed the project files from Notepad and it still keeps opening the wrong file. Why am I as a user being punished so much for one tiny mistake? Why is there no Source > Attach different source... menu?

I had to delete the project and recreate it from scratch to make it work.

7 comments
Comment actions Permalink

This should be possible in Project Structure dialog.

Regards,
Alexander.

0
Comment actions Permalink

Please describe where should I look, because I've looked everywhere and didn't find an option to de-attach the current source jar, and attach a new one.

Project - has SDK and Java language level -- not here
Modules - has 1 module, no subnodes
    - Sources: I have Source folders and Test Source folders -- the jar is not here
    - Paths - everything as default, it's not here
    - Dependencies - several jar files, but the .src.jar is not here
Libraries - empty
Facets - empty
Artifacts - empty
SDKs - empty
Global libraries - empty

So where is it?

0
Comment actions Permalink

Is the jar in subject a module library? Then Project Structure / Modules / the module / Dependencies / select the library / press Edit.

Alexander.

0
Comment actions Permalink

I double click on ReflectionServiceFactoryBean which opens the java file in cxf-2.5.9.src.jar

This means the source file is attached to that jar file, right?

In Dependencies I find the cxf.jar file, right-click and select Edit.

In the Configure Module Library, there is only the jar file. No .src.jar.

0
Comment actions Permalink

Can it be, that the same cxf jar (with .class files) is added to several modules, and sources are attached to one entry, but not another? Then you have to find that entry.

Another case: can it be that the same jar contains both .class and .java files?

Regards,
Alexander.

1
Comment actions Permalink

Hi, Same problem I am also facing, I dont know why nobody has been able to find a solution to this, but it seems very basic.

 

0
Comment actions Permalink

I agree this is unnecessarily complicated to change a source jar. For example when debugging I get a red bar on top telling me my source does not match the .class file, right there should be an option to change the source jar, but took me a while to actually change the source. Tried changing .iml files, I deleted the old source jar, yet IntelliJ somehow still opens the bad source, impressive :) 

0

Please sign in to leave a comment.