Java - Maven

Create a new maven project called 'javabot' with the package name 'annabel82.javabot':

mvn archetype:generate -DgroupId=annabel82.javabot -DartifactId=javabot -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Edit pom.xml file, next mvn command will get dependencies etc:

su vim pom.xml

Make a completely new /target compile – will need to run ‘mvn dependency:copy-dependencies’ afterwards to copy dependencies for runtime:

rm -rf target && mvn clean package

Compile and package:

mvn package

Copy dependencies to /target/depdencies for runtime execution:

mvn dependency:copy-dependencies

View the contents of a jar file:

jar tvf target/javabot-1.0-SNAPSHOT.jar

Run it:

java -cp "target/dependency/*:target/javabot-1.0-SNAPSHOT.jar" annabel82.javabot.JavaBot


To setup log4j, add libs to po.xml:

vim pom.xml

Create log4j conf:

vim src/main/resources/
Root logger option
log4j.rootLogger=INFO, stdout

Direct log messages to stdout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L – %m%n

Update compile dependencies and then compile/package the log4j conf in to our .jar for runtime:

mvn mvn package

Then update runtime dependencies:

mvn dependency copy-dependencies