File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Calling a Java Class in a WebArchive from an external shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Calling a Java Class in a WebArchive from an external shell script

murthy bala
Greenhorn

Joined: Dec 20, 2005
Posts: 9
All,

I need to call a class packaged in my web application from a shell script to pass an argument to the class. To be more specific, the packaged web archive (WAR) will be deployed in an application server and after its deployed i need to call that particular class present in the WAR file on a continuous basis and pass an argument.

Example: Target class file's directory location in the WAR file - WEB-INF/Classes/com/sample/batch/invokeBatch.java

and i need to call this java file from a shell script from my unix home directory and pass it an argument like

./calljob.sh $java_argument

Can anyone suggest how to proceed further on this. Where can i start from to work on the solution?


Bala
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
The "calljob.sh" script invokes the "java" command, correct? If so, you can set up the CLASSPATH variable in the script any way you like, maybe like this:

WEBAPP_PATH=/full/path/to/the/webapp/WEB-INF

CLASSPATH=$WEBAPP_PATH/classes:$WEBAPP_PATH/lib/some-extra-library.jar

java -classpath $CLASSPATH my.package.hierarchy.MyClass $1


Ping & DNS - my free Android networking tools app
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.
 
 
subject: Calling a Java Class in a WebArchive from an external shell script