john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

eclipse maven runnable jar including dependencies eclipse hotkey

maven-runnable-jar-including-dependencies


shift + alt + x  (brings up popup with run options) => m = maven

OR Window -> Preferences -> General -> Keys   (sort by Binding to see what's already defined)

search filter "maven" -> Run Maven Clean => f9

Running Control + F11 will fail as there is no executable for Eclipse to run
    java.lang.NoClassDefFoundError: com/oxygencloud/sdk/util/MyMain
    Caused by: java.lang.ClassNotFoundException: com.oxygencloud.sdk.util.MyMain


search filter "maven" -> (copy command "Run Maven Build") -> Run Maven Build => f10

(VERIFY IN Run As -> Run Configurations -> Maven Build -> getoxygensession exists with goal package)

NOW, the secret hotkey combo is: F9 -> F10 -> Control + F11



MAKE SURE YOU CAREFULLY CONTROL YOUR PACKAGES AND ACCESS MODIFIERS FOR YOUR DEPENDENCIES

package com.oxygencloud.sdk.util;

public class MyMain
{
    public static void main( String[] args )
    {
        System.out.println( "MyMain" );
    }
}




<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>com.oxygencloud.sdk.util</groupId>
  <artifactId>getoxygensession</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>getoxygensession</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>4.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.oxygencloud.sdk.util</groupId>
        <artifactId>OxygenLogin</artifactId>
        <version>0.15-SNAPSHOT</version>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>1.7.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <manifestEntries>
                    <Main-Class>com.oxygencloud.sdk.util.MyMain</Main-Class>
                    <Build-Number>123</Build-Number>
                  </manifestEntries>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

  • « jsp login ip forwarded
  • eclipse maven export as jar »

Published

Aug 21, 2012

Category

java

~184 words

Tags

  • dependencies 3
  • eclipse 22
  • hotkey 2
  • including 1
  • jar 5
  • java 252
  • maven 10
  • runnable 1