I'm trying to use Synthetica library with maven but I failed.
There are 2 different jar file I need to import. First one is synthetica.jar and the other one is syntheticablackeye.jar.
I tried mvn install:install-file but it didn't solve the problem.
I can use them with eclipse but currently I do not use any IDE like eclipse also I'm on linux.
Steps I have done:
(This is for synthetica.jar)
mvn install:install-file -Dfile=~/Dropbox/github/ChatAppServer/synthetica.jar -DgroupId=de.javasoft.plaf -DartifactId=synthetica -Dversion=1.0.0 -Dpackaging=jar
(This is for syntheticaBlackEye.jar)
mvn install:install-file -Dfile=~/Dropbox/github/ChatAppServer/syntheticaBlackEye.jar -DgroupId=de.javasoft.plaf -DartifactId=synthetica -Dversion=1.0.0 -Dpackaging=jar
the problem is how should I add dependency when the to jar files file structers are same?
I did these and It worked fine but when I check local mvn repos in my pc(.m2/repo/) there were no jar files. synthetica and syntheticablackeye file structers are same is this a problem? If it is what can I do?
What am I missing?
Edit: When I change artifactId and groupId maven trying to download jar files but they are in local repo?
You have not supplied any details about any errors you are getting or what command you used exactly to install the JARs, so it is hard to know what exactly is not working.
You can install 3rd party JAR files in your local Maven repository with a command like this (see also Maven's Guide to installing 3rd party JARs):
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id>
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
For example:
mvn install:install-file -Dfile=synthetica.jar -DgroupId=com.synthetica
-DartifactId=synthetica -Dversion=1.0 -Dpackaging=jar
Then you refer to it in the pom.xml of your project with the same Maven coordinates:
<dependency>
<groupId>com.synthetica</groupId>
<artifactId>synthetica</artifactId>
<version>1.0</version>
</dependency>
edit - Do not use the same groupId, artifactId and version for both JAR files, otherwise Maven cannot tell them apart.
Related
Recently I tried to develop an interface for my group. My service runs and works well on my local machine, but when trying to use Maven Compile in IDEA, the compilation fails and tells me it cannot find my JAR package. The JAR package I use is JAVE (Java Audio Video Encoder), which was manually added into my CLASSPATH. I know Maven cannot find JAR package without adding dependency to pom, but I can't find the Maven dependency for JAVE, it seems that they only provide a JAR package for users. JAVE HomePage
So in this case, what should I do if I want to successfully compile my code using Maven? I need to deploy my service in the future, so manually adding JAR package to my CLASSPATH instead of adding dependency to pom is definitely not acceptable.
You can install a maven jar locally using:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
You can install the artefact to either your local or a remote maven repo or you could use it as a system-scoped dependency (see https://stackoverflow.com/a/2177417/9705485 or http://roufid.com/3-ways-to-add-local-jar-to-maven-project/ for examples)
I have a library that is incompatible with java8. It's xws-security:3.0. I can't use it fully because there's trouble in crypto/xmldsig/1.0.
On the screenshot, you can see situation in the intellij idea.
How can I solve this problem by gradle exclude?
You can download it from repository and then install it into your local repo. https://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/javax/xml/crypto/xmldsig/1.0/xmldsig-1.0.jar
Code:
mvn install:install-file -Dfile=xmldsig-1.0.jar -DgroupId=javax.xml.crypto -DartifactId=xmldsig -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true
I have created a project in Eclipse using maven. I am getting an error in my pom.xml in dependency, the dependency look like this.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc5</artifactId>
<version>11.2.0.1</version>
<scope>provided</scope>
</dependency>
I am getting:
Missing artifact com.oracle:ojdbc5:jar:11.2.0.1
I saw a solution in stackoverflow it self, That-
due to Oracle license restriction, there are no public
repositories that provide ojdbc jar.
you need to download it and install in your local repository.
Get jar from Oracle and install it in your local maven repository using
mvn install:install-file -Dfile={path/to/your/ojdbc.jar} -DgroupId=com.oracle
-DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
the above command. I executed the bellow command changing the path to my ojdbc.jar.
mvn install:install-file -Dfile={
C/monitoring-workspace/ojdbc5.jar} -DgroupId=com.oracle
-DartifactId=ojdbc5 -Dversion=11.2.0.1-Dpackaging=jar
but I am getting an error on cmd that
I am confused in two things
My oracle folder it self has ojdbc5 and ojdbc6 jar then why do I need
to install ojdbc5
What should be the path I need to provide while installing ojdbc-the
where I need to install or the path where I have kept ojdbc5 jar.
I see you have referred to mykong article. The problem is new lines. You have to make sure that you got it in one line in the command prompt.
mvn install:install-file -Dfile=C:/monitoring-workspace/ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.1 -Dpackaging=jar
ojdbc6.jar - Classes for use with JDK 1.6. or newer
ojdbc5.jar - Classes for use with JDK 1.5.
you need only one of them
This question already has answers here:
How do I add third-party jars into local Maven repository? [duplicate]
(2 answers)
Closed 7 years ago.
I have a group of aboout 20+ third party jars that I need to add to the RUNTIME of an Eclipse Maven project written in Java. These jars are not available from mvnrepository.com. How can I accomplish this?
I tried Build Path.. Configure Build Path and added the jars manually, but this does not make the jar APIs available in Spring MVC controllers because the jars were added to the Build Path and not to the RUNTIME.
I then tried Project Properties -> Deployment Assembly -> Add -> Archives from file system as per this other posting. This imported the jars into /WEB-INF/lib, but did not make their APIs available.
I then read these instructions for importing 3rd party jars into a maven project, but the instructions say to use this line of code mvn install:install-file -Dfile=<path-to-file>. As you can see, this code only specifies one jar, when I have over 20 third party jars to add. The maven link also does not specify where or when to type the code.
Do I navigate the terminal to the root directory of the Maven repository and then type that line of code with 20 variations, once for each jar?
And do I repeat this every time I do a Maven update from within Eclipse? Clearly there has to be an easier way.
What is the easiest and most effective way to get Eclipse Maven to add all 20+ jars to the runtime of my project, so that my Spring mvc controllers can call the APIs when I try Run As... Run on server, and so that the jars are also bundled up with any war files that get created by Eclipse Maven?**
Edit
#DaveNewton suggested writing a shell script. How would such a script look?
I tried mv /path/to/all/the/jars/* /path/to/workspace/MyApp/src/main/webapp/WEB-INF/lib/ and then typed F5 to make the jars visible in the /WEB-INF/lib folder, but this did not resolve the compilation errors from the code elsewhere in the project that calls the API, even after Project... Clean.
Also, I would like for the Eclipse Maven plugin to be able to manage this as much as possible.
Edit 2
As per #alainlompo's suggestion, I imagine a script that includes the following commands, and then the dependency addition below it. Here is what might be in the script:
mvn install:install-file -Dfile=/thefirst.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
mvn install:install-file -Dfile=/thesecond.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
mvn install:install-file -Dfile=/thethird.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
mvn install:install-file -Dfile=/thefourth.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
mvn install:install-file -Dfile=/thefifth.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
mvn install:install-file -Dfile=/thesixth.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
mvn install:install-file -Dfile=/theseventh.jar -DgroupId=my.group.id -DartifactId=myartifactid -Dversion={version} -Dpackaging=jar
And so on for all 20+ jars.
Here is what the dependency tag in the pom.xml might be:
<dependency>
<groupId>my.group.id</groupId>
<artifactId>myartifactid</artifactId>
<version>what goes here?</version>
</dependency>
I would guess I would add some symbols to the groupid to make sure that Maven cannot find anything with the same name at mvnrepository.com. This way the Eclipse Maven update could be used. But what do I use for the version number? Many of the jars have different version numbers.
Also note I am using linux. What would the actual shell script and dependency tag look like?
I think the simplest way to solve this issue is to add your jars to your maven local repository. There is answer for this on SO here and also here. The jars will then be available in Eclipse but also outside eclipse for any of your project that is using maven as a build tool and where the jar is correctly referenced (with the groupId, artifactId and version dependency informations properly provided) as in the following example:
<dependencies>
....
<dependency>
<groupId>org.matlabcontrol</groupId>
<artifactId>matlabcontrol</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>
And then you may easily write a .bat or a .sh (depending on the OS) that will do this operation once and for all.
[EDIT]
#CodeMed regarding the jars that are behind the link that you've shared in your comments, some of them are related to each others and therefore will share the same version as the same groupId and most certainly different artifactIds
Example:
org.eclipse.emf.common_2.5.0.v200906151043.jar
org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar
Obviously the suffixed 4 parts number is the version number of the jar. So You already have the version number and since it is common to many jar it is to your advantage to define a variable for it in your .bat file and a property for it in your pom.xml file.
Also the groupId will generaly be the same for all related jars. Therefore you could suspect that the groupId would be org.eclipse.emf, and if you google this: maven dependency for org.eclipse.emf + 2.5.0.v200906151043you would find among other links a link to a pom.xml file on a related github project with the following depency informations
I would now be logical to suspect that the artifactId is what's left from the name of the jar commonin one case and ecore.xmiin the other case. This will be checked against a little googling or on Mvnrepository (for example here where we see that this artifact id is also prefixed by the group id)
Therefore we would write the following kind of instructions in a .bat file to install these jars in our local repository
First define a variable to hold the version number
set eclipseEmfVersion=2.5.0.v200906151043
call mvn install:install-file -Dfile=org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar -DgroupId=org.eclipse.emf -DartifactId=org.eclipse.emf.ecore.xmi -Dversion=%eclipseEmfVersion% -Dpackaging=jar
call mvn install:install-file -Dfile=org.eclipse.emf.common_2.5.0.v200906151043.jar -DgroupId=org.eclipse.emf -DartifactId=common -Dversion=%eclipseEmfVersion% -Dpackaging=jar
In the case of the second jar however I find on MvnRepository that the artifactId does not set the groupId as its prefix (see here)
Note also that in a .bat file you need to use call mvn (instead of simply mvn as you would do had you only one instruction to run) to be able to execute many maven instruction sequentially.
On the same pattern you can distinguish another group of related jars with the groupId: org.openhealthtools.mdht.uml.cdaand version number 1.2.0.201405161834. You can apply the same approach to install them in your local repository
Here is the successfull test I run (from a bat file that I created in the same directory where I unzip your file) using the first four jars in your list of jars
call mvn install:install-file -Dfile=net.sourceforge.lpg.lpgjavaruntime_1.1.0.v200803061910.jar -DgroupId=net.sourceforge.lpg -DartifactId=net.sourceforge.lpg.lpgjavaruntime -Dversion=1.1.0.v200803061910 -Dpackaging=jar
call mvn install:install-file - Dfile=org.apache.commons.lang_2.3.0.v201005080501.jar - DgroupId=org.apache.commons -DartifactId=lang -Dversion=2.3.0.v201005080501 - Dpackaging=jar
call mvn install:install-file - Dfile=org.eclipse.core.runtime_3.8.0.v20120521-2346.jar - DgroupId=org.eclipse.birt.runtime -DartifactId=org.eclipse.core.runtime - Dversion=3.8.0.v20120521-2346 -Dpackaging=jar
set cdaversion=1.2.0.201405161834
call mvn install:install-file - Dfile=org.openhealthtools.mdht.uml.cda.ihe_1.2.0.201405161834.jar - DgroupId=org.openhealthtools.mdht.uml.cda -DartifactId=ihe - Dversion=%cdaversion% -Dpackaging=jar
You can easily complete the .bat and after running you may manually check the successfull installation of all the jars in your maven local repository.
I made some jar files (using java and jar commands in CMD) but when I try to install them in a local directory (to use it as may local maven repository) by following command:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
but maven gives me following error:
The goal you specified requires a project to execute but there is no POM in this directory
which means that this command needs a pom file but which pom file (do I need to repackage my code with maven again!)
I recommend not to build the jar with Java but to use maven to build and install it.
1) Setup a new simple Maven project
mvn archetype:create -DgroupId=yourProject -DartifactId=yourProjectsArtifactID -DarchetypeArtifactId=maven-archetype-quickstart
(http://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/simple.html)
2) Place the Java source for your jar into the resulting folder:
...\yourProjectsArtifactID\src\main\java
3) If required declare the dependencies of your code
which should be included in the classpath when compiling it to the POM.xml in ...\yourProjectsArtifactID. You can do so by opening it in a text editor and replicating the existing entry for each jar that you would like to have in the classpath. Change the value in the scope tag to compile or remove it.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
4) Compile and install your jar
Run
mvn clean install
inside the folder in which the pom.xml resides: "...\yourProjectsArtifactID":
first go to your maven conf/settings.xml and define your local repo location:
Repository>E:/repo2/</localRepository>
then go CMD and type:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
NOTE: cause you don't have any pom in this case. you should define all the necessary parameters (groupid, artifactid, packaging and version) otherwise you will get an exception.
NOTE: if in your string, contains spaces you need to surround it with a double quotation ("").
Also note that you can tell the location of your local repo explicitly, by parameter (-DlocalRepositoryPath).
If the above config doesn't work you can save all your config info in a pom file and reference it explicitly like below:
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path to pom file>