I am new to openIMAJ and I want to process some pictures using it. There are a lot of tutorial available but they all tell using Maven. Does anyone know from where I can download the jar files of openIMAJ to directly use in my Java project?
Thanks!
For all the features of OpenIMAJ there are more than 50 Jar file that you need to Download individually. Also if you somehow manage to find all those files manually on internet you may end up mixing some or other version which will make some classes incompatible. Although I would strongly suggest you to try understand what maven is and its capabilities, you can follow the below steps if you dont want to add dependencies using maven or even don't even want to know what it is.
1.) Go to Help Menu -> Open MarketPlace.
2.) Search for maven and download the plugin.
3.) In file menu create new-> new maven project
4.) Select your workspace and click next
5.) In the select an Archetype window look for add archetype and enter the following details
GroupID: org.openimaj
ArtifactID: openimaj-quickstart-archetype
version: 1.1
URL: http://maven.openimaj.org/
6.) Click next and give details of your own project and click finish
All the jars will be downloaded which you can see in your project structure. You can now stop worrying about maven and start concentrating on openimaj.
OpenIMAJ is rather complex and contains a lot of modules that you probably don't need to use in your project (i.e. if your making something to do image processing, you probably don't care to much about audio analysis, or content analysis of web-pages). In addition each of the OpenIMAJ modules has dependencies on numerous other projects (which themselves have dependencies, and so on). For these reasons, it isn't really all that practical to provide direct downloads of all the modules and their dependencies as it would take an incredible effort for the user to try and figure out which bits are needed and which bits are not.
The ideal way to specify which bits of OpenIMAJ you need is to use an automatic dependency management system; this does not need to be Maven however - any Maven compatible dependency manager will work (i.e. Ivy, SBT, Grape, etc...). There are examples of the snippets you need to add to your build system configuration for these on the OpenIMAJ front page in the box on the right (you might need to scroll down a bit).
If you really do want to manually include the relevant jar files in your existing project, I'd recommend the following approach, which uses Maven to build a customised set of jars based on the exact OpenIMAJ modules you need:
Run mvn -DarchetypeRepository=http://maven.openimaj.org -DarchetypeArtifactId=openimaj-quickstart-archetype -DarchetypeGroupId=org.openimaj -DarchetypeVersion=1.2.1 -DartifactId=oi-deps -DgroupId=oi-deps -Dversion=1.0-SNAPSHOT -DinteractiveMode=false archetype:generate to create a basic OpenIMAJ project (called oi-deps in this case).
Go to the oi-deps directory: cd oi-deps
Edit the pom.xml file to include only the bits of OpenIMAJ you need by removing any unnecessary <dependency> sections.
Run mvn dependency:copy-dependencies. This will create a target/dependencies folder that contains all the jars you need to add to your project.
I also didn't find any 'download all' site. And I think the reason is that there are a lot of dependences in some jar files.
I extracted some jars recently to use in a project without maven but that was quite wiry.
And I was only able to do this using another project with maven.
I think maven is good stuff and easy to use within ie. netbeans. So give it a try.
Related
I'm trying to add Maven to already existing java project. It's been quite an adventure. I've read many questions here but I don't quite get it. The app I'm building is kinda modular so I'm loading many classes from URL so that the need of replacing the .exe (wrapped jar) file is at its minimum (Cuz once opened by any user I'cant update - replace the app (.exe)).
Since I'm using wide variety of libraries and the app Jar, hense the .exe, became too large - ~80MB, and slow to open from fileshare. Hense the need of Maven (or so I think). Since I installed Maven I had to add package statement at the top of every class, because before then there was not such thing, nor the need for it. Maven found the dependencies online and for the most part the process was not so time consuming, but the goal is to load the libraries from the project(app) folder /lib/. There I have all the libraries in jar files that I need. My question is: Is there a need of installing the libraries to local m2 directory (as I've read) since the app should always load them from the app folder? How do I configure the POM so the project/lib/ directory is recognized as a repo (or even is this the right approach), and load the libraries from the relative path of the project folder?
Thanks in advance to anyone able and willing to help!
Maven's core objective is to manage dependencies. You can add a dependency to your project, by configuring it in pom.xml, maven will download the dependency from the maven central repository & when building the project, maven can help you create a runnable JAR that have all your dependencies & code compiled.
Let's say in your current project if all of the dependencies are absolutely necessary, then even after migrating the project to maven, you're runnable JAR will remain the same size. There won't be any reduction in your application size. However, I would highly recommend migrating your project to any build tool like gradle or maven to manage project dependencies.
I am creating a java project in IntelliJ (without maven or grandle). The project uses an external library, whose .jar file I’ve put into a /lib directory. After that I had to select at the /lib folder “add as library” to use it.
Now I want to push the project to GitHub, so that some people (who are using IntelliJ as well, but in different versions) can use the project.
Now my question:
Is there a way, that they do not have to do the step “add as a library” themselves?
My first idea was to push also some parts of the .idea folder to GitHub, but I am not sure which ones to push and if that could actually work (especially with different versions of IntelliJ).
Do you have any idea how to solve this issue?
If you are using only IntelliJ for building the project, then yes, you should push the .iml files from the .idea folder (or where they happen to be), since they contain the dependencies configured in IntelliJ.
Note, that projects with multiple contributors typically use a build tool like Maven or Gradle.
This is a special build requirement, which I would use Gradle for. With Gradle you can look up a given folder, like /lib and use all .jar files as dependency.
See Gradle example about exactly what you want.
IntelliJ is handy when you do something simple mostly for learning, but if you want to be a professional one day I highly suggest looking into Gradle. It has a learning curve for sure, but you can achieve such simple tasks like this in your question relatively simply. And as you seem to know, pushing .idea to the repository is really not the nicest thing one can do :)
Just a small additional note: Gradle solves the "different version" problem by including a "Gradle wrapper" inside the repository, so everyone cloning the repository will have the same copy of Gradle as well, so the same build process is guaranteed for all contributors.
Also, when I started programming I downloaded the dependencies and used them as jars. But if you learn at least Maven, and your dependency is uploaded to a repository like Maven Central, you can just paste a line of code into your pom.xml (Maven) or build.gradle (Gradle) and you are good to go :)
I want to use Maven for building my next Java Project.
So I have some questions about Maven before starting right off.
Does Maven need to be installed? Or can Maven binaries just be copied to a system (Windows) and be used in the same way.
Setup a Maven project required?
From a Maven tutorial i've seen that the first step in Maven is to setup a Maven project like this:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Why is that? Is writing a POM file not enough when I only want to compile some Java files and include some jars?
Question 1 (Installation):
Well it mostly is simply copy, add to path, and run.
However in real world there is a bit more than that. For example,
- in a company, you may want to have a company central repository proxy. You will need to do extra set up in either HOME/.m2/settings.xml or MVN_DIR/conf/settings.xml (Wish I remember the path right :P )
You may want to put local repository in a different directory in some case, you will also need to change settings.xml.
In order to have building of big project works, you may need to adjust M2_OPTS environment variable.
etc...
All these things are extra manual installation work you may need (Not difficult though)
Question 2 (Archetype):
You are actually right. You can simply write your own pom.xml and forget about archetype (That's what I was doing in the past too :) ). You can think Archetype as some template-project-generation feature, so that you may generate some pre-defined project types, and the essential project directory structure, required dependencies and settings in POM are all done for you. Of course you may even provide your own archetype, so new projects in your company can make use of them to conform with guideline or standard you want.
Does Maven need to be installed? Or can Maven binaries just be copied to a system (windows) and be used in the same way.
Maven comes bundled as a zip archive that you just need to unzip. You then need to add the bin directory to the PATH environment variable and you are good to go.
Setup a Maven project required? From a Maven tutorial i've seen that the first step in Maven is to setup a Maven project like this:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
There are multiple ways to create a Maven project. However, it is important to remember that a Maven project only comes down to having a single pom.xml file. This file will be located at the root of your project. So you are right when you say that "writing a POM file is enough".
Now, since Maven is a tool that is built under the convention-over-configuration principle, several utilities have been created to help adhere with the basic conventions of Maven. One of those utilities is the maven-archetype-plugin, which is invoked by the call to mvn archetype:generate. This utility will create a basic pom.xml file along with the standard directory layout.
If you are using an IDE, you could also create a Maven project by using the corresponding Maven plugin of this IDE (for example for Eclipse, this is the M2Eclipse plugin).
Answer to 1st question:
Maven is available in distributed binary format.You just have to download it and extract it in your local machine. And then, you have to create one user variable named M2_HOME(sometime M2_OPTS is also required) and add it to PATH variable. That's all you need to set up basic needs.
If your system is inside some proxy network then you have to perform one additional settings. That is to copy secuirity xml, which is available inside the downloaded files, and modify the elements values inside it according to your network.
Answer to 1st question:
For the 1st time you need to use the command you specified. Once you get the file-structure, you may reuse it based on your need. But remember to follow predefined file-structure else you would be surely in a trouble.
However,it's always advisable to create the projects using maven command as it would do many things for you which you might have to do manually if you opt for manual maven project creation.
I am a new IntelliJ user (I've used Eclipse for many years). I'm having a hard time wrapping my head around the-project-is-a-module concept in IntelliJ, since this does not hold true in Eclipse. The main issue I'm having is that I am using my top level package as the project in IntelliJ. I would like this top level package to be in a git repo. I would also like all the dependencies of this package to be in their own respetive git repos. When I check these packages out into my project, a do git status on the top level package, all of the dependencies show up in the untracked files. This behavior seems incorrect to me. How can I fix it?
Thanks!
Edit:
To summarize the clarifications in the comments:
I would like to support hundreds of libraries any of which could change at a time. The dependency graph will also be frequently changing. For this reason, having one git repo or constantly updating .gitignore files is not maintainable.
Currently, I'm using Maven to manage dependencies but I'm open to using whatever is best suited for this job.
Finally, I would like to check out any library into my workspace and modify it and, if possible, have Intellij reflect my local changes when running code as if my local code were already built into the dependency graph. A type of local override if you will.
IntelliJ's directory structure places all of the modules in their parent project's directory. If you are developing libraries which are shared between several other projects, importing the library as a module is probably not the correct solution. Instead, you should treat each library as its own independent project and make "releases" using a build tool such as gradle or maven. Then your projects can treat the libraries the same way they do third-party libraries and use the build tool to import the library.
I've been asked to apply Maven to a project. After browsing a dozen sites it appears that it's quite vast and I'm not familiar as I'd like with similar tools like Ant. Why is it used/preferred and what does it offer over a standard Eclipse project? Also, how could it be added to an existing project?
Why is it used/preferred and what does
it offer over a standard Eclipse
project?
It is a build tool which can build your project without the need for an IDE like Eclipse. It can create a jar or war or other artifacts from the source, performing a bunch of steps like compilation, running unit tests, etc.
Where maven scores over ant is in managing third-party dependencies and in convention over configuration (which mean less lines of build script if you follow convention).
Also, how could it be added to an
existing project?
You start by creating a new maven project, following the step here.
Place it in the root folder of your project
If your source and resource files do not follow maven folder convention, update maven properties suitably referring to this documentation.
Run mvn package
It will fail if it needs any third party dependencies, which you can add as specified in the doc
With some trial and error, you should have your project running with maven, possibly, much quicker than if you were to set up the same with ant.
Others are already provided sufficient resources to read more about maven.
I suggest to start reading here:
http://www.sonatype.com/books/mvnref-book/reference/public-book.html
Maven is a great tool when you know how to use it. Maven (at core) is a dependency manager.
You include in your pom.xml (similar in function to the build.xml from Ant) all the librairies your project depends on (example : apache commons) along with their version and Maven get them directly from a repository (by default, the central maven repository)
Then you do not have to manually install any jar to make your project work. All is downloaded and cached on your local machine. You can even create an enterprise repository where you put all the jars needed by your company
Maven uses the concept of artifacts which are pre-built library projects with their own dependencies
To mavenize a project, you'll have to write a pom.xml describing your project (examples are numerous), get rid of your libs directory (or whatever classpath you described under Eclipse) and add all your dependencies to your pom.xml
You could also check Mavenizer for a first-start
But Maven is a lot more what i've just said. Read the docs, read poms from librairies and you'll get used to it quickly ;-)
If you use the M2Eclipse plugin from Sonatype, it's just a matter of right clicking the project in the package explorer and choosing Enable Dependency Management in the Maven menu. You are also advised to adjust the directories that contain the sources to the Maven standard directory layout but if you absolutely can't, you can configure that later.
Apart from that: Well, look for tutorials and documentation (for example there is the free book Better builds with Maven. Maven is very complex (yes, I don't think it is simple) and very powerful.