You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by cablepuff <ca...@gmail.com> on 2008/09/03 15:45:38 UTC

creating runnable jar file

Hi i have a runnable jar files that depends on hibernate and spring (latest
version of their jar file respectively).

I tried maven-jar-plugin.

              <plugin>
	        <groupId>org.apache.maven.plugins</groupId>
	        <artifactId>maven-jar-plugin</artifactId>
	        <configuration>
	          <archive>
	            <manifest>
	              <addClasspath>true</addClasspath>
	              <mainClass>company.main.execute</mainClass>
	            </manifest>
	          </archive>
	        </configuration>
	    </plugin>

but this doesn't allow me to distribute the file to other machine.

I also tried maven assembly plugin. 

<plugin>
         	<artifactId>maven-assembly-plugin</artifactId>
         	<configuration>
         		<filters>
         			<filter>src/main/filters/build.properties</filter>
         		</filters>
         		<descriptors>
            		<descriptor>src/main/assemble/descriptor.xml</descriptor>
            	</descriptors>
         		<workDirectory>target/assembly/work</workDirectory>
         		<archive>
	               	<manifest>
	                	<mainClass>company.main.execute</mainClass>
	                </manifest>
             	</archive>
         	</configuration>
         </plugin>

my descriptor.xml
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
  <id>jar-with-dependencies</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <dependencySet>
      <outputDirectory>lib</outputDirectory>
      <unpack>true</unpack>
      <scope>runtime</scope>
    </dependencySet>
  </dependencySets>
  <fileSets>
    <fileSet>
      <directory>target/classes</directory>
      <outputDirectory></outputDirectory>
    </fileSet>
  </fileSets>
</assembly>

however i get this error
about namespace www.springframework.org/schema/tx cannot be found. 

Is their a better way to create deployable jar files that runs on different
machine. 

-- 
View this message in context: http://www.nabble.com/creating-runnable-jar-file-tp19289532p19289532.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: creating runnable jar file

Posted by Graham Leggett <mi...@sharp.fm>.
cablepuff wrote:

> however i get this error
> about namespace www.springframework.org/schema/tx cannot be found. 
> 
> Is their a better way to create deployable jar files that runs on different
> machine. 

It sounds like you are trying to create an uberjar, AKA a 
jar-with-dependencies.

An uberjar is a new big jar created by unpacking all the dependent jars 
into one big jar, which being self contained, will run on any machine 
without needing any special classpath setup.

The assembly plugin can create uberjars for you, look at the docs for 
the assembly plugin to see how.

Regards,
Graham
--

Re: creating runnable jar file

Posted by David Brown <da...@davidwbrown.name>.
Hello, something like the following works for me everytime. The only drawback is long compile times on slow machines. HTH, David

**************************************************************
<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>test.Test</mainClass>
                            <packageName>test</packageName>
                            <addClasspath>true</addClasspath>
                        </manifest>
                        <manifestEntries>
                            <mode>development</mode>
                            <url>${pom.url}</url>
                        </manifestEntries>
                        <manifestFile>src/main/java/test/MANIFEST.MF</manifestFile>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <manifest>
                        <mainClass>test.Test</mainClass>
                        <packageName>test</packageName>
                        <addClasspath>true</addClasspath>
                    </manifest>
                    <manifestFile>src/main/java/test/MANIFEST.MF</manifestFile>
                </configuration>
            </plugin>
**********************************************************************
Run this at your POM.XML command-line directory:

mvn clean install assembly:assembly




cablepuff wrote ..
> 
> Hi i have a runnable jar files that depends on hibernate and spring (latest
> version of their jar file respectively).
> 
> I tried maven-jar-plugin.
> 
>               <plugin>
> 	        <groupId>org.apache.maven.plugins</groupId>
> 	        <artifactId>maven-jar-plugin</artifactId>
> 	        <configuration>
> 	          <archive>
> 	            <manifest>
> 	              <addClasspath>true</addClasspath>
> 	              <mainClass>company.main.execute</mainClass>
> 	            </manifest>
> 	          </archive>
> 	        </configuration>
> 	    </plugin>
> 
> but this doesn't allow me to distribute the file to other machine.
> 
> I also tried maven assembly plugin. 
> 
> <plugin>
>          	<artifactId>maven-assembly-plugin</artifactId>
>          	<configuration>
>          		<filters>
>          			<filter>src/main/filters/build.properties</filter>
>          		</filters>
>          		<descriptors>
>             		<descriptor>src/main/assemble/descriptor.xml</descriptor>
>             	</descriptors>
>          		<workDirectory>target/assembly/work</workDirectory>
>          		<archive>
> 	               	<manifest>
> 	                	<mainClass>company.main.execute</mainClass>
> 	                </manifest>
>              	</archive>
>          	</configuration>
>          </plugin>
> 
> my descriptor.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <assembly>
>   <id>jar-with-dependencies</id>
>   <formats>
>     <format>jar</format>
>   </formats>
>   <includeBaseDirectory>false</includeBaseDirectory>
>   <dependencySets>
>     <dependencySet>
>       <outputDirectory>lib</outputDirectory>
>       <unpack>true</unpack>
>       <scope>runtime</scope>
>     </dependencySet>
>   </dependencySets>
>   <fileSets>
>     <fileSet>
>       <directory>target/classes</directory>
>       <outputDirectory></outputDirectory>
>     </fileSet>
>   </fileSets>
> </assembly>
> 
> however i get this error
> about namespace www.springframework.org/schema/tx cannot be found. 
> 
> Is their a better way to create deployable jar files that runs on different
> machine. 
> 
> -- 
> View this message in context: http://www.nabble.com/creating-runnable-jar-file-tp19289532p19289532.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
Yet some, not wise, go to the other side of the globe, to barbarous and unhealthy regions, and devote ten or twenty years, in that they may live,-that is, keep comfortably warm,- and die in New England at last. 

Henry David Thoreau - Walden - 1845


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org