How to make jar of a Project dependent on another jar - java

I want to package my files into jar,but these are dependent on Apache HttpClient jars. So is there any way to package all into single jar ??

You can put the dependency jars into your project's jar. Here is some info.

You can use a build tool like Maven to manage project dependencies easily. If you are using eclipse all you need to do is to install maven plugin and than you can create maven projects(or you can also convert your existing one).
After creating maven project you can manage dependencies by making entry into the pom.xml file.
You can do something like this :
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.2</version>
</dependency>

Related

Maven project architecture

I am trying to add the locally created project which contains JARs added using java build path to my maven project as dependency and the JARs used in the dependency project are also be useful in the main project. how to deal in this scenario if I don't want to convert my dependency project to maven?
You have different possibilities:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>2.53.1</version>
<scope>system</scope>
<systemPath>
C:/.../your-jar.jar
</systemPath>
</dependency>
or you can install it in your local .m2 repo
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
This doesn't force you in any way to convert your project into a maven project, but let you reuse the jar you already have.
This is similar like Maven multimodule project. In that all the submodules gets added to the root project as a jar after successful compile. In your case try covert the project into jar and copy the same jar file to the lib folder of parent project.

How to connect Java Applocation to JIRA?

I want my java application to communicate with JIRA how can i achieve this functinality. I mean what configuratons are need to add, what are jar files etc ?
You actually don't need Jar files if your java project is using Maven. Just add maven dependency
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${atlassian.product.version}</version>
<scope>provided</scope>
</dependency>
If you are not using maven as build system to your project. Download jar from maven directly and add it to your project.
Follow the documentation https://developer.atlassian.com/server/jira/platform/java-apis/ and start development

NoClassDefFoundError on Maven dependency present locally

I am new to Maven Project. I am making changes to one of the open source maven project. I am facing a problem in adding a library to the project. So far i have done this :-
I added a library named jni4net.j-0.8.8.0.jar to the resources folder of the project.
I right clicked the jar(in Intellij) and clicked 'Add as library'.
Then in the pom.xml i added:-
<dependency>
<groupId>jar.0.8.8.0.jni4net</groupId>
<artifactId>jar.0.8.8.0.jni4net</artifactId>
<version>0.8.8.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/jni4net.j-
0.8.8.0.jar</systemPath>
</dependency>
But when i build this project(build is successful, test cases are running) and use this it throws following error:-
java.lang.NoClassDefFoundError: net/sf/jni4net/Bridge
Please help me resolve it. I am new to maven and pom. I have looked at various answers, but not getting it right.
PS - I named groupId and artifactID as just reverse of jar file
This is not the right way to add that dependency.
All you need is:
<dependency>
<groupId>net.sf.jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>
The dependency will be retrieved from Maven Central when you build.
Using <systemPath>...</systemPath> is highly discouraged as it usually ties your project to a local environment.
Since jni4net.j dependency is available in maven central, You don't have to download and put the dependency manually. Maven will download and store the dependency locally in `'.m2' folder. Just add dependency as bellow.
<dependency>
<groupId>net.sf.jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>

Rebuild java project from compiled one

There is a java project built with Maven. I have project sources, need to improve something and then rebuild the project.
The problem is one of Maven dependencies is now lost (seems like it was only in developer's local repo). But there is a compiled project (.ear). I suppose it has code from that Maven dependency.
Is there a way to build a project using old project's compiled files?
Extract the required jar from old ear, and in new pom add that jar as dependency,
<dependency>
<groupId>GroupId</groupId>
<artifactId>ArtifactId</artifactId>
<version>VersionNo</version>
<scope>system</scope>
<systemPath>path/to/the/jar</systemPath>
</dependency>
You can use the compiled jar's and put them into library folder and rebuild path.

How to use this library with Eclipse

I'm trying to use this library https://github.com/axet/vget
I can't seem to figure out how to get a .jar file out of that so I can use it.
Well, you can put the below dependency in your pom.xml if you use Maven.
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.5</version>
</dependency>
Otherwise, you could download the archive from https://github.com/axet/vget/releases and build it yourself.
If you want the latest (unreleased) version, you'll have to clone the repository on your machine and build it yourself.

Categories

Resources