0

I have a Maven Project in Eclipse (Oxygen) and I can successfully run its code inside Eclipse. The project's source code also resides in a Git repository.

I would now like to deploy the project on another host (without Eclipse) with all its dependencies and run it there. I assume this is done by running a combination of git clone, mvn install, and java.

What are the exact steps I have to follow in a case like this?

rookie09
  • 736
  • 1
  • 6
  • 18

1 Answers1

1

The following now works for me (mvn exec:java courtesy of this previous answer):

# host runs Debian 8.9
apt install openjdk-8-jdk
apt install maven

# run as Java application
git clone <git-repository>
mvn clean install 
mvn exec:java -Dexec.mainClass="<main-class>"
rookie09
  • 736
  • 1
  • 6
  • 18
  • I would certainly hope you're packaging this into a jar, which could just be run via the system's `java` command. – Powerlord Oct 31 '17 at 09:27
  • @Powerlord Maven creates a jar with my core classes as part of `mvn install`. The challenge is with all the project's other dependencies. Copying them into a single jar as well would be a hazzle, which Maven helps to avoid (at least to my current understanding). – rookie09 Oct 31 '17 at 09:38
  • 1
    You should take a look at the [maven shade plugin](https://maven.apache.org/plugins/maven-shade-plugin/index.html), which creates what is otherwise known as an "uberjar" which packages all your dependencies into it. – Powerlord Oct 31 '17 at 09:41