I am working on maven project in eclipse and I have some 7-10 jar files. I have added dependency of those jar files in my POM file. But when I click any function which is part of libraries, my eclipse complains that no source code found. All jar files are successfully downloaded in my local maven repository. I am struggling to attach source code. I have already tried downloading sources and Javadoc under maven but it is still not working.
You can use a tool to decompile .jar files, for example this.
Other option is use the Jetbrains IntelliJ IDE that includes a potent decompiler right out of the box.
Please check if you have Maven Dependencies on your build path
I suggest you use more popular IntelliJ IDEA IDE rather than eclipse, you can view jar source code easily.
Related
I right clicked on dependency JAR files in a netbeans maven project and tried downloading source and javadoc, this was done successfully by Netbeans, however now I dont see a way to access the source JAR and javadoc JAR.
Please let me know how to obtain the source and javadoc jars, esp where they are being stored by the IDE currently.
Arvind.
Typically in ~/.m2/repository on *nix or C:\Documents and Settings\$USERNAME\.m2\repository in Windows
My problem is with a project where I use the POI library. It's from apache and allows you to work with excel,word, ... .
I had to add some jar files to my library and it runs perfect.
The problem is when I put my JAR file somewhere else.
It gives me the errors it can't find the librarys.
Is there a way I can put my librarys into the 1 jar?
I already tried to add my lib folder as source package but that didn't help.
there is a Maven plugin for Eclipse called M2Eclipse, which will read a POM and construct a classpath out of jars it finds in the local repository and any remote repositories you've configured. It behaves largely like Maven does in terms of finding the latest version for a given jar (if you've specified a version range in your POM).
You can also have a look on this
http://fredpuls.com/site/softwaredevelopment/java/deploy/five_strategies_for_managing_j.htm
You want to make a 'shaded' or 'uber' jar, which has all of its dependencies included
There is a maven plugin for building a shaded jar.
https://maven.apache.org/plugins/maven-shade-plugin/
For me the fastest/ easiest solution was to just open my project in eclips and export is a runable JAR then it adds the librarys to the JAR.
NetBeans builds your application into the project's dist folder. There is also a readme file in it, that tells you, you should distribute the contents of that folder...
Edit
Remove the lib folder, that is shown on the second image, from your sources.
I created a new Maven project and generated Javadocs through eclipse. It created a lot of html files in the project directory inside a folder called "doc".
Now I want to distribute this project as a dependency to my colleague and he does not have the source of the project I created. He is only adding my project as a dependency. He says he cannot see the javadoc when he hovers on a method that I created in my project.
What am I missing here?
Add the maven-javadoc-plugin to the project (plugins section of your pom.xml), instead of generating the Javadocs through Eclipse. Please have a look at the jar goal. If done correctly, the Maven build will package a javadoc jar beside the normal jar file. The build will result in following jars:
${artifactId}-${version}.jar
${artifactId}-${version}-javadoc.jar
If you want to provide the sources additionally, the maven-source-plugin (goal jar) will do the job for you.
The installation of the jar file, the javadoc file and in case the source file into your colleague's local Maven repository can be done with the maven-install-plugin.
I have downloaded the open source edition of AlgoTrader from google code and imported it in Eclipse. There are two project algotrader and algotrader-strat. But the problem is that they are not recognized by eclipse as a java projects. I realized that when I tried to add a jar file and build the path. There is not āJā on the project folder. So my question is there a way eclipse to recognize these projects as java. And if yes how can it be done?
Thanks.
https://code.google.com/p/algo-trader/wiki/AlgoTraderDocumentation#Installation
As it uses maven, maybe you can just regenerate the Elipse project files. Something like:
mvn eclipse:eclipse
I just did a quick look at the mentioned projects (I do not know them).
From what I can see, the directories you imported are the parent projects (from a Maven point of view), whose modules are in some sub-directories. For example the algotrader project contains a sub-directory called code. This one is an Eclipse project that can be imported.
I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir. Cd into that dir and ran mvn command without any arguments but I got bunch of errors. I am absolutely new to maven so I think I am missing something. I tried also from Eclipse ( Import project -- exisitng maven project) but that also does not work except eclipse creates a project that has just that file pom.xml. I expect something that first it will download the jar for the project and then download all dependent jars and config files but nothing there.
So given a pom file how do I build the project from it?
mvn install should get you going
I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir ...
It sounds like you only have the project's POM file. This is not sufficient. You need to checkout the complete source tree for the project. Having done that, change directory to the directory containing the POM file and run mvn install.
Also, don't copy the POM to a different directory. Maven expects to find all of the source files relative to the POM file location.
FOLLOW UP
Thanks for advice. I was not able to use the command mvn install as it gave errors.
Probably because you hadn't checked out the source.
I don't know how to check the source tree of the project ...
Use a subversion client (the svn command for example), or one of the Eclipse subversion plugins.
If this was a properly documented project, there would be clear instructions on what version control and build tools you needed, how to checkout the source code and how to build it.
... as I thought POM itself should have this information to automatically checkout if the source is not check out.
It doesn't necessarily, though in this particular case it does.
Anyway I was able use Eclipse to build the project without errors.
(Other readers can read #icyrock.com's answer for links to the m2eclipse plugin and documentation.)
The only problem is the dependent jars were downloaded but hidden deep paths in .m2 repository folder on my linux box.
But I would like these dependent jars to be relative to dir where POM file is.
Sorry, but that is not the way Maven works.
The ~/.m2/repository directory is a fundamental part of Maven. It is not a problem. It is a feature. (Don't fight it!)
If you want to open this within Eclipse, you need to install m2eclipse:
http://www.eclipse.org/m2e/
and then import the project as a Maven project as described here:
http://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html
Try out their getting started guide. It has a lot of good examples:
http://maven.apache.org/guides/getting-started/