Howto run chapter01 sample code from Spring in Action 4th edition on the command line

Add this to build.gradle:

task copyToLib(type: Copy) {
    into "$buildDir/libs"
    from configurations.runtime
}

build.dependsOn(copyToLib)

This makes sure that the jar dependencies are copied to the lib directory,
when you build the project.

Save this in a batch or bash script file, in the Chapter_01 directory:

linux:

#!/bin/bash
cd knight/build/libs
java -cp *:. sia.knights.KnightMain

windows (haven’t tested it, but this should work):

cd knight\build\libs
java -cp *;. sia.knights.KnightMain

(* adds all the jars to the classpath and . adds the current dir. to the classpath)

command line

Advertisements

One thought on “Howto run chapter01 sample code from Spring in Action 4th edition on the command line

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s