I want a jar file for the project https://github.com/klout/brickhouse but I don't see any link on the site which gives me jar file. There is a link on right menu to download the project as zip file.
I found similar question How to create single jar file from github tree?, but I have dependencies in the pom.xml. I'm using eclipse and win-7. One way I can think of is create a new project in eclipse, add all java packages and files, get all dependency jar files from pom.xml, download them and add to class path. But this will be a lengthy process. Any help is much appreciated. Thanks.
There's a Getting Started section in the project's README that shows the steps to follow to do just that. I just tried them and they work just fine:
$ git clone http://github.com/klout/brickhouse
$ cd brickhouse
$ mvn package
$ cd target
$ dir
That's it! You have to have Maven installed of course.
A little late in responding, but Brickhouse has a separate Downloads page in the wiki
https://github.com/klout/brickhouse/wiki/Downloads
Also, if you are using maven or ivy, it should be available in the sonatype public repo.
http://central.maven.org/maven2/com/klout/brickhouse/
If you are using maven to build a jar assembly, add the following lines in your pom.xml
<dependency>
<groupId>com.klout</groupId>
<artifactId>brickhouse</artifactId>
<version>0.5.5</version>
</dependency>
Related
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.
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 need some tools to read JSON from a URL. However, when I tried to use the JSONObject class, it was unavailable. I looked it up and it was suggested that I should download the required library : https://github.com/douglascrockford/JSON-java
I'm unfamiliar with downloading and creating a jar of Github repositories. I have downloaded the repository in zip fromat. ( I am using windows 8). I navigated to the location, extracted the files and tried to create a jar.
I found half of the solution in : How to make this (github) source into a library/jar?
Based on the Suggestion i used the command to make jar:
git clone git://github.com/douglascrockford/JSON-java
cd JSON-java
jar cf JSON-java.jar *.java
I got a jar generated in the folder, I dragged it over to the library folder in my eclipse project.
However, I still don't find any of the required classes available while coding.
Additionally, I tried compiling the code >javac *.java and then tried the jar creation step but no avail.
What steps I missed?
When you have to attach external library in Java, generally you should have jar with compiled sources.
What we have in repository is source code, nothing more, so you can't just pack it and get compiled files (*.class).
So, your options here are at least so:
Download compiled jar, provided by author and attach it to the project within Eclipse (How to import a jar in Eclipse)
Use maven project, for which you can define dependency on some external project: http://mvnrepository.com/artifact/org.json/json/20140107
Compile the project yourself (not recommended): in Frederic Henri's answer
not sure what you mean with the compilation of java file and "no avail"
but you need to compile java files before you package them as jar :
mkdir build
javac -d build/ *.java
then package the build directory as jar
jar cf JSON-java.jar -C build/ .
then import the jar file in your library of the project - make sure to add it in your eclipse lib settings and you should be able to reference the org.json package
I downloaded protobuf-2.5.0.tar.gz, extracted it, did the usual ./configure, make, make check, and make install. However, the file protobuf.jar which seems to be needed for using protocol buffers in Java does not seem to be part of what I downloaded. Worse, I cannot find this file anywhere. Please advise me how to proceed.
You can add it as a Maven dependency:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
</dependency>
All dependency information is available at Maven Central, or just download the .jar file directly.
To generate the protobuf.jar file, you need to do what Bruce Martin suggests, but you then need to do the following:
Navigate into the src/main/java/com/google/protobuf directory
Make a directory called bin
Run the following command to build the .java files: $ javac -d bin *.java
Navigate into the bin directory, and finally, run the following command to generate the protobuf.jar file: $ jar cvf protobuf.jar com/
Then, copy and paste the jar to wherever you need it.
You can download ProtoBuf Jar from
Here
then you can put jar inside libs folder
and if want to get Protobuf repository from maven then
add inside pom.xml file.
Hope it will help..
The simple solution is that you should compile the jar by yourself.
Download the src code from https://code.google.com/p/protobuf/downloads/list
Unzip it and follow the instruction in README
Here is what you should do in Linux
./configure
./make
You can install the protoc by run ./make install
Then you need the jar, let me assume you are on ubuntu
install maven first
sudo apt-get install maven
Then follow the instruction in /java/README.txt
If you want the standard jar
mvn package
If you want the lite version
mvn package -P lite
Then you can find the jar in /java/target
I am presuming you are on linux, Try going to the java directory, there is a readme file telling you how to create the jar with / without maven. You will have to create the jar from the supplied sources.
The without maven instructions are:
1) Build the C++ code, or obtain a binary distribution of protoc. If
you install a binary distribution, make sure that it is the same
version as this package. If in doubt, run:
$ protoc --version
If you built the C++ code without installing, the compiler binary
should be located in ../src.
2) Invoke protoc to build DescriptorProtos.java:
$ protoc --java_out=src/main/java -I../src \
../src/google/protobuf/descriptor.proto
3) Compile the code in src/main/java using whatever means you prefer.
4) Install the classes wherever you prefer.
you can download this jar from here
http://mirrors.ibiblio.org/maven2/com/google/protobuf/protobuf-java/2.5.0/
Like all Maven projects, you can get the project jar by clicking "DOWNLOAD (Bundle)" from the project site.
If you look at the URL scheme of the bundle link, you'll notice you can go a directory higher to see all available files for that release, including a sources and javadoc jar.
To create protobuf.jar file using protobuf java follow below steps:
1.Check installed protobuf version:
$protoc --version
2. Install Java and Maven , Check their version:
$mvn --version
$java -version
3. Generate the protobuf.jar file , go to /protobuf/java directory. Run the below commands,
$mvn test
$mvn install
$mvn package
Check /protobuf/java/core/target/ directory,The .jar will be placed in the "target" directory.
You can download google's protobuf.jar from this link
This page serves almost all the jars that you need for development. I downloaded and use it in project
Would you like to download ".jar" file and exclude maven. then
Try it link
"https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/2.6.1/"
Should click this link.
"https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/"
then you look all version.
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/