How to get java runtime source? - java

I am using maven, when I click some method of JDK from Eclipse, I received the error like
"Source not found". I am wondering how to get the source code of JDK from Maven?

Which class(es) are you attempting to look at? Assuming you installed a JDK and configured Eclipse to use it - and not a JRE, which doesn't contain the src.zip with the source code, this should work in most cases. An exception is for many (if not all) of the com.sun.* classes and others that are only available under the SCSL or the JRL licenses - which is available through a separate download from Oracle, after accepting one of these licenses.

I don't know what Maven has to do with this. You can find the JDK source in the src.zip that comes with your JDK. I don't know how to tell Eclipse to use it: I'm an IntelliJ user. There must be an attach source plug-in or command hidden in there somewhere. Point it at your src.zip and you're in business.

If you want to attach the source code of JDK, please reference Attach the Java Source Code
If the source you want to look is from third-party library like spring, you can tell maven to download the source code when you generate eclipse project
mvn eclipse:eclipse -DdownloadSources=true
But not all source can be download unless the source code maven artifact is published to maven repository.
Even more you can download Java doc with this argument when generating eclipse project
mvn eclipse:eclipse -DdownloadJavadocs=true
You can get more info from Maven Eclipse Plugin Link
Hope this will help you.

Related

How to debug third-party Intellij IDEA plugin?

So, I am using a plugin from the Intellij IDEA Marketplace and I'd like to modify it to my needs. The plugin is Open Source(Apache License) but I couldn't find its source code on the internet. I know that plugins are located under Users directory in Windows, so I could decompile the jar and see the source code. But the problem is that this plugin contains some dll files as well.
Is there an easy way to debug the plugin and set breakpoints etc. to see where I will need to modify the code(the other option would be to include the decompiled java source files in a new plugin build but I don't know what to do with the existing dll files).
Thank you.
Intellij Idea plugin development requires a project structure and it requires gradle-intellij-plugin. If you are able to compile the source code, you have to create gradle project with gradle-intellij-plugin. First of all follow the links to create a small plugin to understand how to create a plugin.
https://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system.html
As a sample project, you can refer below the github project.
https://github.com/debjava/ddlab-gitpusher-idea

IDEA not showing JavaDoc for decompiled Java class files

I don't see the documentation in my Maven project for Java dependencies that are decompiled from .class files. It does work for external Maven dependencies.
I have activated the following settings.
Settings->Importing->Automatically Download->Sources & Documentation
And also, right click pom.xml and download documentation there.
How can I make IDEA fetch documentation for these core Java files?
Refer screenshots below to see examples of both scenarios.
You need to make sure the sources are attached to the JDK configuration. It should work out of the box, but it could be that your JDK installation is incomplete and is missing the sources.
src.zip must be present in the Sourcepath of the JDK configuration:
Try reinstalling JDK from the official download page and configure it again in IntelliJ IDEA.

How to compile/update github java file

There is a working jar file on Github version 1.4 (https://github.com/ggodlewski/smux-anki-converter/downloads)
The original author has updated the code to versions: 1.5, 1.6 and 1.7 but they are not standalone working jar files but mere zip files containing:
.classpath,
.gitignore,
.project
pom.xml
and some of the folders contained in the working version 1.4.
Version 1.4 is about 7MB and the updates are only about 45kB each.
The project itself seems to be dead and I cannot get in touch with the author.
My question is: how do I make those updates work? How to update version 1.4 to 1.7 on my PC?
I have tried to figure it out using Eclipse import/export but I am not a programmer and I just don't know how to do it.
Please help.
You should be able to build from source as follows:
Make sure that you have a Java JDK installed. Java 6 or later is required, but I would advise Java 7 or Java 8.
Make sure you have Maven installed and configured. (If you need to use an HTTP proxy to access the internet, you will need to instruct Maven ...)
Use git clone <url> to create a clean sandbox.
Change directory to the sandbox.
Run mvn assembly:assembly to build. (That is what the README file says ...)
The first time you do this, Maven is probably going to download a lot of stuff from the Maven Central repo.
If it works, the built JAR(s) will be somewhere in the target subdirectory.
(Note: I haven't tried this myself. YMMV.)

How to attach java docs to jar in osgi plugin?

I'm trying to attach the java docs in my eclipse IDE and I am a little bit confused.
I've seen an answer where I had to click on project> properties> JavaDoc location> then insert java doc/api.
Yet another said I had to click on Window> prefernce> Installed Jre>edit> select /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar.> attach java doc/api. I did that for all the jar files
In both cases, it doesn't seem to work. I still see the not attached java doc message for packagejavax.jms. I'd like to have the doc for all the classes I have in my eclipse project. It is an osgi project so I'd like to do it for the whole project and not for individual plugins.
****UPDATE****
Also tried using maven eclipse integration i.e install plugin> click on download artifact source and javaDoc. Didn't work.
It looks like it has to do with the plugin dependencies. When I attach the java doc to the jar in the plugin dependency and restart eclipse there's no javadoc attached. I guess there's another way of doing so with jars found in Plug-in dependencies.
Can anyone help? Thanks.

Are Apache Ant Javadocs Included in the Eclipse Plugin?

I was trying to add Ant libraries to a project in eclipse, and I used the ones that were part of eclipse's plugins folder. When I tried to associate them with Javadocs, I couldn't locate them in the plugin folder. I searched for them online, and I found this page, in which they say the docs are not provided online because they are part of every distribution. So where can I find the docs in the distribution that came bundled in Eclipse?
The ant javadocs may or may not be included with eclipse, depending on which version you have. Edit: Anyway, it's better not to depend on the version bundled with the IDE. Otherwise everyone who works on the project will have to use the same version of the IDE, and eclipse automatic updates can break your project.
Download the ant binary distribution and ant source distribution
Take the eclipse ant distribution out of your project and replace it with the binary jars (extracted from the zip).
In the eclipse java build path window attach the source zip to the binary jars. (Click the plus, double click "Source attachment" and select the source zip. You'll be able view the source if you want, and the javadoc will appear in the appropriate views.
I do not completely agree with Motlin's answer:
the process described is correct ("attach the source zip to the binary jars"), except the source code of all ant components is provided with eclipse distribution.
If ant is a plugin for eclipse, in [eclipsePath]\eclipse\plugin\org.apache.ant_1.7.1, [eclipsePath]\eclipse\pluginalso contains org.apache.ant.source_1.7.1.jar, including within it all the sources.
I confirm [eclipsePath]\eclipse\plugin\org.apache.ant_1.7.1 is there, but only in the SDK distributions of eclipse with sources included:
SDK eclipse (or "classic eclipse)
Modeling
RCP for plugin development.
This table summarizes the eclipse distros which come with sources included.
So, in the event you do not have access to any other ant stand-alone deliveries, you could use one of this eclipse distros to program and find in it a full ant distribution.
However, as pointed by Motlin, that is not the safest path to consider.

Categories

Resources