Create a .sh file

type the command in .sh to excute the java class:

1. Considering the jar file is an excutable one.

java -jar <jar-file*>

*jar-file – But here the Main-Class attribute must be mentioned in the Manifest file.

2. Not considering the jar file is an excutable one.

java -cp <related jar files*> package.ClassName

*related jar files
– Jar files must be seperated by semi-colon in windows and a colon in Linux.

eg :

java -Dlog4j.configuration="file:log4j.xml" -cp /mysystem/jboss-4.0.3SP1/server/default/deploy/jbossweb-tomcat55.sar/my-libs/xmlParserAPIs.jar:/mysystem/jboss-4.0.3SP1/server/default/deploy/jbossweb-tomcat55.sar/my-libs/updater.jar common.currency.exchange.server.XRatesUpdater

Excute the sh file in terminal using bash command.
eg : bash fileName.sh

Advertisements