I have a problem with Eclipse Indigo regarding library source code. When I open a library class (e.g. from the JDK, but also from some other included libraries, such as Guava), either using the Open Type dialogue or simply through Ctrl+ click on the class name or some of its methods, once in a while (not always) something breaks.
Don't get me wrong, the source is always displayed without any problem (either JDK source shipped with the JDK itself or Guava source downloaded by Maven). What actually stops to work:
When I open the Quick Outline popup in that given class using Ctrl + O, the list of methods and fields displays normally, but when I click on any of them, Eclipse doesn't move the view on it as it should. Also Ctrl + clicking any of the methods or fields of that class in my code doesn't bring me directly to it, but simply at the top of the source file.
When I hover over that said class or its methods, no JavaDoc appears in the popup as you can see in the attached image. I am in the HashSet class, the source is clearly there, but it isn't displayed in the popup.
I found out that this can be fixed by opening the Outline View and briefly clicking through the class's methods and fields. After a few clicks, Eclipse catches on and starts to work correctly, but only for this one class, not for all which are broken in this way at the moment.
Has anybody met this kind of bug? Is it tracked at Eclipse Bugzilla? Thanks in advance for any advice.
For completeness, this is my configuration:
Windows 7 Professional x64
Oracle JDK 1.7 Update 2 32b
Eclipse Indigo for Java EE Developers 32b
your issue #2 may be resolved by following these steps :
Go to http://java.sun.com/j2se/1.5.0/download.jsp and choose to
download the JDK 5.0 Source Code.
For JDK 5.0, select Download(SCSL source).
Download JDK (SCSL) 5.0 (1.5.0). This will give you a file jdk-1_5_0-src.scsl.zip. You do not need to unzip this file; Eclipse likes it the way it is.
In Eclipse, go to Projects -> Properties -> Java Build Path -> Libraries and expand JRE System Library [jre 1.5.0], then rt.jar. Select Source attachment and click Edit...
Select the above zip file. and Finish by exiting the dialog boxes.
source
Hope this helps..
Sounds like wrong sources are attached to the libs inside Eclipse.
I had similar symptoms in a project where a class exist in both: inside a lib and in the project's src folder. Same canonical class name, but different implementations.
I would recommend to verify (or reinstall) your JDK-Installation and re-configurating it in Eclipse.
Hitting Ctrl+Shift+T and typing HashSet and taking a screenshot of that window may help here, too.
To answer my own question, I didn't find out how to solve the problem in Indigo, but updating to Juno fixed it.
Related
I have some Java classes which are marked in red in project view, but IntelliJ IDEA shows no errors and it can run properly. What can be the problem?
It means that the files exist locally, but are not in the repository, and are not scheduled for addition. With other words, the files are not under version control. There is not really a problem since the files can just be added to the VCS if desired. This can be done using Add to VCS from the context menu or the shortcut ⌥⌘A (Mac) or Ctrl+Alt+A (Windows).
See File Status Highlights in the official documentation of IntelliJ IDEA for other colours and their respective meaning. See Manage files under version control for how to put the files under version control.
They are not added to version control repository. Select them, and then CTRL-ALT-A ( or menu via right click ) will add them. Green means there are changes needed to commit
Click File -> Synchronize, and IntelliJ should see that everything is okay again.
If that doesn't work, IntelliJ's caches might be corrupt.
Clicking File -> Invalidate Caches and restarting the IDE
Src
Sometimes files are being marked as red because of inconsistence in project settings and build files.
Recently I've checked out some project. The project look well and compile well, but all class names in the code were red.
The IDE felt well all the modules paths and even hinted class names, which on been agreed turn red immediately.
When inspected, the ant build model was set to the 1.8 language level, while the default ide module setting was 14.
When I set module language setting level to 8, all the red highlight disappeared.
So I believe language level to be checked to match everywhere in your project.
I have the JD-eclipse-plugin installed. I want to decompile the classes within a jar-file. So I select the jar-file within Project-Explorer and click Decompiler in the Menu. However both decompilers (JAD and JD-core) are greyed out.
I also tried the steps shown in this blog on AVAJAVA Web Tutorials. I guess the blog is a bit outdated, however I can see within Windows-->Preferences-->Java-->Decompiler that Jad is correctly set up. But there is no JD-eclipse found within Preferences-->General-->Editors-->File Associations as you can see in the following image.. Now I right click the jar-file within Project-Explorer, but there is no such "Attach Source File".
Did I miss anything to set up the plugin?
EDIT: I´m using the following setup: Eclipse: Mars.1 Release (4.5.1); JadClipse 4.0.0; JDK 1.8
EDIT2: Forgot to mention that I use Tomcat and want to dive into the libraries from /WebContent/WEB-INF/lib. This is not working, I cannot further collapse the jar-files.
For Eclipse 2018-09 , the problem was related to " class without source
"
I had resolved this issue by going to:
Preferences
General
Editors
File Associations
Class without source
and setting decompliler viewer as default : see the following screen shot:
Obviously I mixed the actual JD-eclipse-plugin an a plugin called JadClipse for Eclipse which is a slightly different plugin from eclipse marketplace. Thus when I followed the installation instructions of JD-eclipse, I could set the options for the screenshot posted within the question. So I set JD-eclipse as default for both *.class-files with and those without source-code.
Second mistake I did was a pretty silly and obvious one, namely that I wanted to browse the jar-files from within WEB-INF-folder of my Tomcat instead of from within Java Resources. Thus I could not dive into the jar-files at all hindering me to get to the class-level and thus to decompile those classes contained within the jar.
I hope this helps anyone outside also having trouble with the plugin for eclipse.
I had the same problem but "class without source" did have decompliler viewer as default. So all I did was set class file viewer as default and then switched back and that fixed the issue.
I had to update all of my plugins. the Procyon decompiler has this symptom when running under java 11 or later.
How do I configure IntelliJ to access offline documentation (for both Java and Android if possible) without leaving my IDE? I'm using IntelliJ IDEA 13.1. My Android application is building and running fine so my installation seems to be correct. I've examined the relevant SO posts:
How to view JDK external documentation in IntelliJ IDEA?
JDK documentation in IntelliJ IDEA on Mac OS X)
IntelliJ and the android java docs
But either the paths they recommend are not on my machine (the posts are rather dated) or else too vague. Interestingly my /Library/Java/JavaVirtualMachines folder seems to be empty whether I use Finder or Terminal. My Documentation paths tab under the File | Project Structure menu item is empty.
I should add that I'm attempting to use the Shift+F1 keyboard command when I have a keyword highlighted. That's what is recommended, but nothing happens. Below are pics of my current documentation paths in the Project Structure dialog. All done according to recommendations as far as I can see, but maybe someone can spot something.
I think configuring the path to src.zip should be enough, IntelliJ will retrieve the Javadoc from the source files. In Modules Settings, in the SDKs panel choose your current SDK, go to the Sourcepath tab and make sure there's an entry for src.zip.
On OSX it's located under
/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/src.zip
or
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/src.zip
depending on which SDK you have and how you installed it.
For the Android doc, I guess you can do the same if they provide a zip containing all the source files.
Command + ; open Project Structure
on left panel select SDKs
in Sourcepath tab click +, select your src.zip
I wrote a project in eclipse with an older version of java.
Now on a different computer but running the same codes I'm getting a whole lot of red.
This is due to Version incompatibility.
I've had my professor change the Java version from within the console window before. The code compiled just fine after he did so. I'm sure its the same case with this code.
After looking at other tutorials and google links I could only find command line approaches and #override methods. To be honest I still don't understand these.
What is the best way to change the version of a code originally written in an older code inside the eclipse console?
thanks!
In eclipse go to Window -> Preferences -> Java -> Compiler, there you can change the java versions. Hope it helps.
Ideally if we want to have two different versions of Java [say 1.6 and 1.7], then we should have two workspace defined accordingly to avoid any mixup. We can also change the Project Facets if our projects has facets that is.
In Eclipse Follow steps given below:
1) Windows -> Preferences -> Java -> Compiler and as per the image set the compliance compiler level as per your requirements.
2) Windows -> Preferences -> Java -> Installed JRE's and check if your required jre/jdk is available or not as given in image below:
3) Right Click on Your Project and go to Java Build Path and check if your required Library is available or not as per image given below:
4) Now you can edit the JRE System Library or add one by clicking on button's available on last image's right side, then a pop up as given below will open up. Here, you can change the execution environment [default values also can be set]
In myeclipse select the project -> properties -> java compiler -> there you can specify jdk version.
Easy
Download the jdk from Oracle's official website for the version you want to compile your project with.
JDK Oracle's official
create a new Java project
[
Once the project has been generated, If you select the part that says Configure JREs
By default eclipse will use the version you have installed on your system so if you don't change this configuration you will never be able to run the program with the build you need, in this case I will use jdk 1.8.
After pressing Add
5.1 And choose the option select the 3rd option in this case, called Standard VM and press Next
Now eclipse asks us to indicate the path where the libraries and other content is located in order to compile and run the program, we only have to indicate the directory where it is located.
As my goal is to run a program with the JRE 8 , I will look for the directory path where the download described in option 1 of this message is located.
As a quick example, since I just want my program to compile without worrying about anything else, I will add all the contents of my address.
Now we change by clicking on the JRE we want to compile our program, to be changed to the original default so that the new selection is executed ; and finally we press Apply and Close and Next
Press Finish to create the project
Now we have the whole project with all the necessary content to compile and run it.
Personally I think this is the quickest and cleanest way to do it ; the problem I encountered when I changed JDK is that when compiling I couldn't find the directory with the necessary components to run it, you had to download it and configure it together with the default parameters, which can cause a lot of headaches for less experienced users.
Finally, this is the version of eclipse that I am using
I hope you find this system useful, I use it to be able to run old examples that use applets , which are obsolete classes and jvm does not compile.
I have recently got a new computer and I have put Eclipse Helios on there. Before, on my old computer, when I used the control-assist (Ctrl + Space) and highlighted the suggested methods, the Javadoc for that method used to appear at the side of the control assist pop up window with the method description and parameters etc...
However, on my new computer this Javadoc doesn't appear and only the method suggestions appear - but even the arguments for the methods aren't named (they're just called arg0, arg1 and so on). The only thing I can think of that is different on the new install is ZoneAlarm but as far as I can see I have allowed eclipse through the firewall; unless it's something to do with Java itself.
This feature is really useful to me so any advice on how to resolve this issue would be greatly appreciated. Thanks in advance.
Eclipse is using a JRE instead of a JDK as the default Java.
Download and install a JDK.
In Eclipse Preferences, Java -> Installed JRE's. Use "Add" or "Search" to locate and add the JDK just installed.
Move the check mark indicating the default Java to the newly found JDK.
Allow the workspace to rebuild.
You need to press F3 on the Class or Method name you want to see javadoc for. Then in the editor it's source will open or if you don't have source attached, you'll have screen with bytecode saying that no sources attached. Then you need to open package view, by default it's on the left side. On the top of it there is an icon with two arrows, if it's not pressed, press it. It will show source you've opened in the package view, then you need to find jar file containing your source by scrolling up if you already don't stand on it.
Now press right mouse button on that jar, you'll see properties window. Select javadoc, then you need to select location of the javadoc. You can provide a URL to an online javadoc. The URL you will be pointing to must provide a page named 'index.html' or similar or Eclipse won't allow you to use that URL. Also you can download javadoc locally and then select the location of that javadoc archive. If you need the javadoc for java SE libraries, you can find it in your jdk installation directory in src.zip folder. Hope it'll help.
Did you specify the javadoc location of your library?
Window -> Preferences -> Java -> Installed JREs -> Select your JRE -> Edit -> Select .jar file(s) (rt.jar) -> Javadoc Location