This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Deploying standalone app with Maven 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Deploying standalone app with Maven 2" Watch "Deploying standalone app with Maven 2" New topic
Author

Deploying standalone app with Maven 2

Klaas van Gelder
Ranch Hand

Joined: Jul 08, 2004
Posts: 100
Dear Maven-experts
I am a Maven newbie and encounter the following issue:
I am developing a pretty simple standalone dataconversion application (with a public static void main(...) method) which imports a number of XML files, parses them and writes some of the data to a database. Nothing special...
Now I want to use Maven to manage the project, define the dependencies, run the unit tests etc. This works without major problems.
But I also want to be able to "deploy" the application, in the sense of running it as an executable jarfile outside Maven or Eclipse.
The problem is: when I run <mvn install>, the generated jarfile contains the compiled sourcefiles, but not the libraries defined in the <dependencies> section. So it does not run.
When I define the packaging as "rar" instead of "jar", a rarfile containing the dependency jarfiles (but not the compiled sourcefiles) is generated.
But what I actually want is a (executable) jarfile containing BOTH the compiled sourcefiles AS WELL AS the dependencies, so it will run without the need to manually copy the libraries and setting the classpath to them...
With Ant, this will not be a big problem, but with Maven... ?
I think it should be a pretty straightforward action to deploy a standalone application containing all needed dependencies using Maven... Do I overlook something ? How can I do this ?
Please, all info is more than welcome !
Best regards, Klaas


"What you don't know, can't help you"
SCJP (81%), SCWCD (81%), SCJD (354/400), SCBCD (85%)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

That pretty much describes how a WAR works. I suppose in a pinch, you could make a WAR and rename the resulting file.

There are some differences, however. A stand-alone JAR execution doesn't add embedded jars into its classpath the way that web app servers do, and I don't know offhand if you can add meta-inf data to WARs using Maven (specifically the Main-Class item).


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Deploying standalone app with Maven 2
 
Similar Threads
how to deploy portlet in pluto portal with tomcat server
Maven cannot delete jar on Windows when executing clean
Adding jndi.properties to 'Class-Path:' in generated jar file
NX:What is the name of uploaded jar file?
[Maven] Configuring libs for WARs inside EARs