When we develop a project, if we want to use struts or tiles or spring or anything else, we have to import some jaf files (into project build path or lib folder)
So I want to ask, is there any website/tool that specify which .jar files we need for each purpose so that I don't have to add a lot of jar files into my project
I'm sorry if this question is irrelevant. I just don't know where to ask :(
Nice day ^^
Use Maven. It is a build/dependency management tool which enables you not to download any dependencies manually, you just have to define it in a configuration file that you need a specific version of a library and it takes care of it all. Also you can use a number of so called archetypes which are basically skeleton applications for a specific set of technologies.
I do agree with abalogh
Use Maven or Ant & Ivy for your needs
When you turn into serious development, you can go without these tools. Test both and choose whichever is good for you. Don't listen to trolls about this or this technology (Mine is better ! No, it's Mine), go to websites, learn to use and make your choice. Then stick to it to get the best out the tool you choose
Cheers
Grooveek
Related
I have a source code of some java library, so what is the preferable way of using it? Where should I put it? Should I jar it? Or compile it? Or go ahead and use it as is?
It depends on many factors, are there more than one people working on the project, will there be for long, do you have access to a corporate maven or ivy repo, to mention a few.
If it is only relevant to that webapp, put it in the project, if you use it in other projects make it a separate project, if it is a codebase that will never change, make it a separate library and make a release out of it so that you don't have to compile it and run its tests on every build.
The list goes on and on, but I hope it helped a little bit at least.
I have a Java application (a quite large one with many external .jar dependencies as well as dependencies on images) and I need to package it up so that someone can double click to run, for example. Or something easy like that.
It uses Java Persistence, so it requires a sql connection which is specified in the Persistence.xml file in the Java Project.
How can I package this up? I was thinking:
the installation process should validate that the user has MySQL installed and if not, direct them to install it
the installation process could ask the user to enter credentials for any database and then I could update the Persistence.xml at run time
These were two ideas I had...but I wasn't sure if there was a known solution to this problem. Any help would be much appreciated!
I think you should take a look at embedded database solutions, like H2. Also, you can package your application using maven's shadowing or jar plugin, having the jar-with-dependencies profile activated.
This will nicely rid you of checking for database servers running on the client machine, and also will give you the proper means of bundling the application in one nice JAR, albeit a little large.
Maven is a build ecosystem and toolset especially designed for building Java applications and executing the code -- and generally doing whatever else you can imagine that's possible to do with and to your code.
It has a rich API for developing plugins and many developers have exploited this feature. There are numerous plugins for building -- and launching -- and packaging your application as well as helping you manage your applications dependencies.
Maven's shadowing comes in the form of maven-shade-plugin, available here. What it does is that it helps you create a single JAR file from all your dependencies. Also, there is the maven-jar-plugin which offers a profile jar-with-dependencies. It is also accessible from here.
H2, on the other hand is a full-fledged RDBMS. This is the website: http://www.h2database.com/html/main.html, and here is a tutorial.
You can find information on embedding the database here:
How to embed H2 database into jar file delivered to the client?
Embedding the Java h2 database programmatically
h2 (embedded mode ) database files problem
I would also suggest you use a combination of H2/Hibernate/Spring which is a very easy setup and provides you with really rich features and an easy-to-use API.
I hope this helps you :)
Building a sophisticated installer that checks lots of dependencies, and runs on lots of different platforms (which I assume you want) is complicated.
I suggest that you look at an installer generator; see What is the best installation tool for java?
Another alternative that I've seen in a few products is to write a (non-GUI) installer or configurer in a scripting language like Perl.
I wrote an installer using ANT, but has no GUI. Also, I used Iz Pack (good option), so I think that depends on how smart do you want it to be, if you are supposed to use it, or a non-technical person, etc.
All my other colleagues use Netbeans, but I have an opportunity to use IDEA. Will we be able to work on the same Java EE projects together, or will we have issues with projects, checking in and out of SVN, etc?
We primarily develop EE and Spring MVC applications using Glassfish on our desktops, and commit to an SVN, although it is possible that I may have to load a coworker's entire projec.
As long as you are using some standard, IDE-agnostic build tool like maven, I see no problems. I work on IntelliJ IDEA while my colleagues use Eclipse - no issues except different formatting rules or import order - all of this can be customized.
Subversion (or any other VCS) is the least of your problems. Even if the rest of your team pushes Netbeans project metadata files, IntelliJ will simply ignore them.
If you use Maven as your build tool, then yes (and Eclipse too).
All three have tooling allowing them to work well with Maven projects.
If you are using "plain" Netbeans projects I do not think that IDEA can work with them. If so, I suggest you lobby for the change. Maven is one of the investments that pay well of.
Why would you want to fly in the face of convention and be the only one on a different IDE? You'll waste time on issues that nobody else has, have formatting hiccups, struggle with pair programming etc.
As much as I like freedom of choice, the development environment within teams should be consistent.
I thought build tools like ant, maven or gradle are de-facto standart of java ee industry. Purpose your teammates to use it.
You will have issues with sharing projects, because the project folder and structure for Netbeans and IDEA is different.
However, you can attempt to share your src folders with one another and update your codes with one another through SVN, though I wouldn't advise it for compatibility reasons because you won't be able to properly share libraries and use other team functionality available in NetBeans.
So it won't be a good idea to use a different IDE so you don't waste time debugging compatibility.
Also, its useful to note that IDEA uses its own custom libraries for certain functionalities, and also build projects in a different way from NetBeans, so projects that appear to work on IDEA may not work on NetBeans and vice versa.
Bottom line, don't waste your time using a different IDE from the rest.
I'm new to java programming and I would like to work on some kind of game engine / lib. Just as a hobby project / experiment. I would like to make some sort of library with classes and utility functions to be able to re-use some generic game code and then a seperate application where I would build the actual game.
I am using intelliJ as an IDE. I was wondering if I could use, change and test a library with an application at the same time and how I would do this?
There are two aspects here. The technical: How does it work? The organisational: Is it a good idea?
The technical is quite easy. You just create different projects. The application project depends on the library project. Libraries are packaged as jars typically. Easiest would be to use a tool that supports you with dependencies and different versions of the library. I would recommend Maven for this.
The second question is harder and probably belongs to https://softwareengineering.stackexchange.com/ as it is more of a philosophical kind and no definitive answer exists. In my point of view it is a bad idea to develop a library and a product at the same time. Specificals of your product will slip into the library, you will get problems with priorities.
That is, when you are developing a library that should be used or published independently of your application. Modularisation of an application is another cup of tea, but could be done with the same tools. With Maven you would setup a multi module project then.
What do you mean by a library? A JAR right, a JAR contains a set of classes, what you would do is to "use, change and test" the classes you would like to make a library and when everything is done, you package it as a JAR and there you are done! If you want the JAR to be created everytime you "build" try using Maven or Ant that does these packaging tasks for you automatically. Maven is more powerful and you would love to see that it mainly does "dependency management" and your library is the dependency for your project.
According to What is Maven the objectives are:
Making the build process easy
Providing a uniform build system
Providing quality project information
Providing guidelines for best practices development
Allowing transparent migration to new features
Can I just make a build script in bash instead?
What is the motivation of using a maven project? Is there any example?
Maven also does dependency management pretty well. This is one of the bigger selling points, but there are a lot more.
It also helps to enforce a standardized project structure. The beauty in that is that I can pick up any mavenized project and pretty much immediately know where all the various files are.
Maven also has a pretty extensive library of plugins that allow for quite a bit... from automating static code analysis (via pmd/findbugs/checkstyle, etc), calculating test coverage, generating javadocs, generating source jars, running a web app in Jetty, etc, etc.
I will tell you that it's not exactly an easy tool to learn, but if you do master it, you learn to appreciate all it can do. If you want me to go into specifics about anything in particular, let me know.
Maven is a tool that handles a lot of the boilerplate project setup and configuration for you. For example, if you wanted a Java project to properly integrate with a build server, provide code coverage information, and produce a jar file that can easily used in other projects around your organization - you could spend weeks setting this up manually using ANT, or you could just 'embrace' the Maven way of doing things.
In addition, you can setup archetypes (and many already exist) that are pre-configured projects for your desired setup. This can be a great way to enforce standards and increase productivity within an organization.
Maven does provide rules that are a bit rigid, but in the end it greatly cuts down on the time required to do many different tasks. I would recommend Maven: The Definitive Guide from O'Reilly as a resource to review.