Making a runnable .jar with dependent libraries for dummys

Making a runnable .jar with dependent libraries for dummys..

Can someone outline the steps I have to take to making a runnable .jar with dependent libraries for dummy with Maven and Eclipse.

I want to use Maven to load the dependent jars but will be using eclipse to do all my coding.... can this be done? I started a projects but Eclipses does not see the dependent libs in my pom.xml file so I am getting errors as I am coding.

Here is my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.runnablejar</groupId>
    <artifactId>RunnableJAR</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>RunnableJAR</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>fully.qualified.MainClass</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

and I dont know why this code is giving me errors in eclipses

package org.runnablejar.RunnableJAR;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Hello world!
 *
 */
public class App 
{
    private static Log log = LogFactory.getLog(App.class.getName());

    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}
Answer:1

You could either:

  1. Use the m2eclipse Maven plugin for Eclipse to make the project maven-aware,
  2. Use the mvn eclipse:eclipse maven goal to generate a proper .classpath file.
Answer:2

When I compile a ruby file to a java class using jrubyc, I get different output when compiling with just jrubyc and with jrubyc --java (to generate the java file) and just javac. Why? Example: First ...

Say I have a 3x4x5x6 java double array a that I unroll into an ArrayList b of length 360 in the following way: for (int i = 0; i<a.length; i++){ for (int j = 0; j<a[0].length; j++){ ...

I am basically making a battleship guessing game where you have to the position of a ship by the click of your mouse. When a position of the ship is guessed correctly it deletes that ship cell from ...

Estoy tratando de instalar el marco de extracción DBPedia siguiendo el http://wiki.dbpedia.org/Documentation He descargado la versión binaria de Maven. $ mvn --version Apache Maven 3.0.4 (r1232337; ...