This extends the 01: Docker Tutorial – compile & run Helloworld.java. Maven pom.xml
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<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.myapp</groupId> <artifactId>helloworld</artifactId> <version>1.0</version> <build> <plugins> <plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.0</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.myapp.Helloworld</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project> |
The run.sh file
|
1 2 3 4 5 |
#!/bin/bash mvn clean package chmod -R +x target/helloworld-1.0.jar java -jar target/helloworld-1.0.jar |
Create src/main/java folder Maven requires .java files to be in the folder src/main/java folder. So create the folder and move com/myapp/* under…